【问题标题】:JSF command button is not compileJSF 命令按钮未编译
【发布时间】: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>

发生了什么?

【问题讨论】:

    标签: java jsf jsf-2


    【解决方案1】:

    显然,什么也没发生。你的配置有问题。 Tomcat 根本不解析 JSF 代码,只是逐字返回。

    请发布您的 web.xml 配置。

    【讨论】:

    • 显然问题出在tomcat上。我已更改为 tomcat 7 并运行正常
    猜你喜欢
    • 2011-07-09
    • 2017-10-04
    • 2014-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 2010-10-13
    相关资源
    最近更新 更多