按照netbeans 6.8 JSF教程,表单不显示
正如标题所示。我正在关注 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您的 web.xml 中包含:
面孔/index.xhtml
<欢迎文件列表>
make sure that your web.xml says:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>