0

I'm a newer to JSF.Currently I met a problem when I start a JSF project.My IDE is eclipse,I created a xhtml as follow:

 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:c="http://java.sun.com/jsf/core" 
      xmlns:f="http://java.sun.com/jsf/facelets">

   <h:head> 
   <title>Jsf page.</title> 
   </h:head> 

   <h:body> 

     <table> 
    <tr> 
       <td>Username:  <h:inputText id="username" /> </td> 
    </tr> 
    <tr> 
       <td>Password: <h:inputSecret id="password" /></td> 
    </tr> 

     </table> 

   </h:body> 
</html>

Finally,the page in broswer just display Username and Password without input text box,it seem all tag with h: prefix dosen't work.

This is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>PlatformA</display-name>
  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>NewFile.xhtml</welcome-file>
  </welcome-file-list>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.forceLoadConfiguration</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
    <param-value>1</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DEVELOPMENT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>com.sun.faces.allowTextChildren</param-name>
    <param-value>true</param-value>
  </context-param>
  <servlet>
    <display-name>FacesServlet</display-name>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
</web-app>

And my face-config.xml:

<?xml version="1.0"?> 

<faces-config
    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-facesconfig_2_0.xsd"
    version="2.0">


</faces-config>

Could anyone can tell me why?what's wrong with my project?Thank you in advance.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Joe
  • 31
  • 1
  • in addition to the answer that you will find in the link provided by BalusC, I want also to note that you don't need the ` javax.faces.DEFAULT_SUFFIX .xhtml ` as it's already the default extension – Tarik Mar 03 '15 at 15:09
  • Appreciate it,I always input url in *.xhtml pattern,so FacesServlet dosen't work:) – Joe Mar 04 '15 at 02:16

1 Answers1

0

Add the *.xhtml to Pattern.

<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
pL4Gu33
  • 2,045
  • 16
  • 38
  • It's also a good way to avoid FacesServlet in *.xhtml pattern dosen't work,thank you! – Joe Mar 04 '15 at 02:17