JSF tags not showing

I am new to JSF, but my JSF tags do not appear in the xhtml file, I tried all possible solutions, but the problem is not solved.

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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> <display-name>JSFProject</display-name> <welcome-file-list> <welcome-file>JSFProject/index.html</welcome-file> <welcome-file>JSFProject/index.htm</welcome-file> <welcome-file>JSFProject/index.jsp</welcome-file> <welcome-file>JSFProject/default.html</welcome-file> <welcome-file>JSFProject/default.htm</welcome-file> <welcome-file>JSFProject/default.jsp</welcome-file> </welcome-file-list> <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>*.xhtml</url-pattern> </servlet-mapping> </web-app> 

my example.xhtml

 <?xml version="1.0" encoding="ISO-8859-1" ?> <!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Example</title> </head> <body> <h:form> Some random data: <h:inputText/><br/> <!-- Textfield ignored --> Some other data: <h:inputText/><br/> <!-- Textfield ignored --> </h:form> </body> </html> 

I spent 3 days figuring out the problem, any help would be appreciated

+4
source share
6 answers

Symbols for JSF components that are not parsed at all indicate that FacesServlet not running. This will happen when the request URL does not match the url-pattern FacesServlet , as defined in web.xml . This would mean that the actual url-pattern for the FacesServlet not *.xhtml at all. You study and edit the correct web.xml , which do you think you are? Is web.xml right deployed using webapp in servletcontainer?

+16
source

I had the same problem, I fixed it by updating below: Martin mentioned above. Thank you

web.xml

 <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> <context-param> <param-name>javax.faces.application.CONFIG_FILES</param-name> <param-value>/WEB-INF/faces-config.xml</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> 

faces-config.xml

 <application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> 
+2
source

Try:

 <?xml version="1.0" encoding="ISO-8859-1" ?> <!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Example</title> </head> <body> <f:view> <h:form> Some random data: <h:inputText/><br/> <!-- Textfield ignored --> Some other data: <h:inputText/><br/> <!-- Textfield ignored --> </h:form> </f:view> </body> </html> 

I have included the JSF tag <f:view>

+1
source

Man, you did not set the javax.faces.DEFAULT_SUFFIX context javax.faces.DEFAULT_SUFFIX . The default value for jsf is jsp , so jsf will look for example.jsp instead of example.xhtml . Basically, jsf replaces the extension of the resource requested with javax.faces.DEFAULT_SUFFIX .

Use the following and it will work:

 <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> 
0
source

Do you have face-config.xml that declares Facelets as a view handler?

 <?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_1_2.xsd" version="1.2"> <application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> </application> </faces-config> 

Remember the javax.faces.DEFAULT_SUFFIX parameter, which must be set to .xhtml, as described above.

0
source

Add the following to your web-inf / lib file:

JSF-api-2.0.9.jar JSF-Facelets-1.1.14.jar JSF-osusch-2.0.4-b09.jar JSTL-1.2.jar

without jsf-facelets * .jar, you cannot display the jsf view.

And, following the example of your web.xml:

  <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>/jsf/*</url-pattern> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> 

Without more than two url templates, tomcat will not be able to display the .xhtml file correctly.

And, faces-config.xml:

 <?xml version="1.0" encoding="UTF-8"?> <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> 
0
source

All Articles