JSF only works with .xhtml ending

I start by programming the JSF website. At the moment, all files have the ending .xhtml. When I go to http: // localhost: 8080 / myProject / start.jsf , everything is fine. But when I rename the file from start.xhtml to start.jsf, I became a NoClassDefFound Error.

What's my mistake?

<servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.PROJECT_STAGE</param-name> <param-value>Development</param-value> </context-param> 
+4
source share
3 answers

You need to change the javax.faces.DEFAULT_SUFFIX parameter (in web.xml)

 <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.jsf</param-value> </context-param> 

However, this is not recommended - use .xhtml or .jsp for your files. Please note that you can use .jsp with facelets without problems (if, for example, autocompletion of your IDE does not work for .xhtml ).

Also note:

  • face servlet mapping determines how jsf pages link in terms of http
  • The DEFAULT_SUFFIX parameter indicates the file extension.
+6
source

Why do you want to rename start.jsf file? The correct JSF .xhtml file .xhtml (but you can change this default extension, as Bozho pointed out).

In fact, this extension is defined by Facelets (or JSF 2.0, since it initially integrates Facelets), which is different if you use "basic" JSP files.

+1
source

It is best to stay with .xhtml because this is the right way to do this, but you can configure it using javax.faces.DEFAULT_SUFFIX context-param in web.xml.

0
source

Source: https://habr.com/ru/post/1299117/


All Articles