开发者

JSF works only with the .xhtml ending

i start with the programming of a JSF Website. At the moment all files have the .x开发者_运维技巧html 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>


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜