按照netbeans 6.8 JSF教程,表单不显示

发布于 2024-08-21 19:21:13 字数 2051 浏览 3 评论 0原文

正如标题所示。我正在关注 JavaServer Faces 2.0 教程(此处) -搜索“声明这些组件”以大致找到我所在的位置。

一切正常,直到某个点,但是当我被告知注释掉 html 表单组件并取消注释 JSF 表单组件时,没有任何显示。如果我推荐 JSF 表单并使用 html 表单,则效果很好。据我所知,我完全按照教程进行操作。有什么想法吗?

作为记录,这就是我的 index.xhtml 的样子:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
    <!--<h:outputStylesheet name="css/stylesheet.css" />-->

    <title>Greeting</title>
</head>

<body>
    <div id="mainContainer">

        <div id="left" class="subContainer greyBox">

            <h4>Hi, my name is Duke!</h4>

            <h5>I'm thinking of a number

                <br/>
                between
                <span class="highlight">1</span> and
                <span class="highlight">10</span>.</h5>

            <h5>Can you guess it?</h5>

            <!--<form action="response.xhtml">
                <input type="text" size="2" maxlength="2" />
                <input type="submit" value="submit" />
            </form>-->
            <h:form>
                <h:inputText size="2" maxlength="2" value="#{UserNumberBean.userNumber}" />
                <h:commandButton id="submit" value="submit" action="response" />
            </h:form>
        </div>

        <div id="right" class="subContainer">

            <img src="duke.png" alt="Duke waving" />
            <!--<h:graphicImage url="/duke.png" alt="Duke waving" />-->

        </div>
    </div>
</body>

As per title. I'm following the JavaServer Faces 2.0 tutorial (found here) - search for "To declare these components" to find roughly where I'm at.

Everthing works up until a certain point, however when I'm told to comment out the html form component, and uncomment the JSF form component, nothing displays. If I recomment out the JSF form and use the html one instead, it works fine. As far as I can see, I've followed the tutorial exactly. Any ideas?

For the record, this is what my index.xhtml looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <link href="css/stylesheet.css" rel="stylesheet" type="text/css" />
    <!--<h:outputStylesheet name="css/stylesheet.css" />-->

    <title>Greeting</title>
</head>

<body>
    <div id="mainContainer">

        <div id="left" class="subContainer greyBox">

            <h4>Hi, my name is Duke!</h4>

            <h5>I'm thinking of a number

                <br/>
                between
                <span class="highlight">1</span> and
                <span class="highlight">10</span>.</h5>

            <h5>Can you guess it?</h5>

            <!--<form action="response.xhtml">
                <input type="text" size="2" maxlength="2" />
                <input type="submit" value="submit" />
            </form>-->
            <h:form>
                <h:inputText size="2" maxlength="2" value="#{UserNumberBean.userNumber}" />
                <h:commandButton id="submit" value="submit" action="response" />
            </h:form>
        </div>

        <div id="right" class="subContainer">

            <img src="duke.png" alt="Duke waving" />
            <!--<h:graphicImage url="/duke.png" alt="Duke waving" />-->

        </div>
    </div>
</body>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-08-28 19:21:13

确保您的 web.xml 中包含:
<欢迎文件列表>
面孔/index.xhtml

make sure that your web.xml says:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文