0

我正在使用 netbeans 开发一个 jsf Web 应用程序。

    <fieldset>
        <div>
           <h:inputText id="firstname" value="#{loginCtrl.customer.name}" label="Name">
                  <f:validateLength minimum="3" maximum="8"/>
           </h:inputText>
        <div>
...

我编写了该代码,但是当我将它部署到 apache tomcat 服务器时,没有显示任何字段?为什么?h:input 没有可见性元素?

提前问候和谢谢

PS.:我的 web.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/register.jsf</welcome-file>
    </welcome-file-list>
</web-app>
4

2 回答 2

1

确保您在浏览器地址栏中看到的请求 URLFacesServletweb.xml. 您可以通过在浏览器中右键单击页面并查看生成的 HTML 源来验证这一点。如果<h:inputText>仍然存在,则意味着FacesServlet根本没有调用 。

If you open the page by /page.xhtml, then the FacesServlet is apparently not mapped on *.xhtml, but on *.jsf or something else. You'd need to change the URL in browser's address bar accordingly to match exactly the specified URL pattern, or to fix the mapping accordingly.

于 2012-05-05T11:37:57.377 回答
0

h:input has no visibility element?

是的,该h:inputText元素具有rendered属性:

<h:inputText id="firstname" rendered="true" value="#{loginCtrl.customer.name}" 
    label="Name">
      <f:validateLength minimum="3" maximum="8"/>
</h:inputText>

但是默认值是正确的,所以问题不在于...

于 2012-05-05T11:21:40.313 回答