【发布时间】:2011-07-05 19:59:53
【问题描述】:
您好,我正在学习 JSF 2.0 使用tomcat 6.0.26
当开始一个简单的页面时,h:commandButton 不显示,并且浏览器中的 html 源显示<h:commandbutton value="Click (Good)" action="successful-test"></h:commandbutton>
代码:
<!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">
<h:head><title>JSF 2.0: Server Test</title>
<link href="./css/styles.css"
rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<div align="center">
<table border="5">
<tr><th class="title">JSF 2.0: Server Test</th></tr>
</table>
<p/>
<h:form>
<fieldset>
<legend>Valid action</legend>
Click button. You should get success page.<br/>
<h:commandButton value="Click (Good)" action="successful-test" />
</fieldset>
<p/>
<fieldset>
<legend>Invalid action</legend>
Click button. You should get error message about not being
able to find matching navigation case.<br/>
<h:commandButton value="Click (Bad)" action="bogus-outcome" />
</fieldset>
</h:form>
</div></h:body></html>
tomcat运行后的html代码:
<!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">
<h:head><title>JSF 2.0: Server Test</title>
<link href="./css/styles.css"
rel="stylesheet" type="text/css"/>
</h:head>
<h:body>
<div align="center">
<table border="5">
<tr><th class="title">JSF 2.0: Server Test</th></tr>
</table>
<p/>
<h:form>
<fieldset>
<legend>Valid action</legend>
Click button. You should get success page.<br/>
<h:commandButton value="Click (Good)" action="successful-test" />
</fieldset>
<p/>
<fieldset>
<legend>Invalid action</legend>
Click button. You should get error message about not being
able to find matching navigation case.<br/>
<h:commandButton value="Click (Bad)" action="bogus-outcome" />
</fieldset>
</h:form>
</div></h:body></html>
发生了什么?
【问题讨论】: