开发者

How to use parameter "javax.faces.FACELETS_SUFFIX" in jsf 2

开发者 https://www.devze.com 2023-04-12 23:32 出处:网络
I have understood the meaning of jsf 2.0 context parameters \"javax.faces.DEFAULT_SUFFIX\" and \"javax.faces.FACELETS_VIEW_MAPPINGS\" with some examples. But I\'m not clear about parameter开发者_JAVA百

I have understood the meaning of jsf 2.0 context parameters "javax.faces.DEFAULT_SUFFIX" and "javax.faces.FACELETS_VIEW_MAPPINGS" with some examples. But I'm not clear about parameter开发者_JAVA百科 "javax.faces.FACELETS_SUFFIX".

According to the documentation:

javax.faces.FACELETS_SUFFIX": Allow the web application to define an alternate suffix for > Facelet based XHTML pages containing JSF content. If this init parameter is not specified, the default value is taken from the value of the constant DEFAULT_FACELETS_SUFFIX which is "xhtml".

So If I want to change jsf file extension from xhtml to xml, I have below settings:

<context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>

But when I access the page in web browser, I get a HTTP 404 error.

If I change the settings as below:

<context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>
<context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    <param-value>*.xml</param-value>
</context-param>

Then when I access the page in web browser, it works.

Can someone explain me what is the real meanning of parameter "javax.faces.FACELETS_SUFFIX"?


It has to go as <context-param> in webapp's web.xml file.

E.g., when you want to change it from .xhtml to .xml:

<context-param>
    <param-name>javax.faces.FACELETS_SUFFIX</param-name>
    <param-value>.xml</param-value>
</context-param>
0

精彩评论

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

关注公众号