views:

98

answers:

3

Hello, i start with the programming of a JSF Website. At the moment all files have the .xhtml ending. When i go to http://localhost:8080/myProject/start.jsf everything is all right. But when i rename the file from start.xhtml to start.jsf i became a NoClassDefFound Error.

What is 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  A: 

You have 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 advisable - either use .xhtml or .jsp for your files. Note that you can use .jsp with facelets with no problems (if, for example the auto-complete of your IDE doesn't work for .xhtml).

Also note that:

  • the faces servlet mapping determines how the jsf pages are referred to from http perspective
  • the DEFAULT_SUFFIX parameter indicates what's the extension of the files.
Bozho
Thank you, this works
ThreeFingerMark
A: 

Why do you want to rename the file start.jsf? The correct extension of the JSF files are .xhtml (but you can modify this default extension, as stated by Bozho).

In fact, to be precise, this extension is defined by Facelets (or JSF 2.0, as it natively integrate Facelets), which is different if you use "basic" JSP files.

romaintaz
A: 

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

Neville Flynn
With the .xhtml extention i can download the Page with the Code. And Eclipse dont make the code completion with .xhtml files
ThreeFingerMark