Welcome page in JSF

2020-02-12 14:00发布

How can I use a JSF page as welcome file? The FacesServlet is mapped on *.jsf and the <welcome-file> is set to index.xhtml. However, it does not show the JSF components. I tried to set the <welcome-file> to index.jsf, but this results in a HTTP 404 error.

I'm using Tomcat 6.0 and JSF 2.1.

标签: jsf-2
2条回答
混吃等死
2楼-- · 2020-02-12 14:32

Adding it to your welcome-file-list like this:

<welcome-file-list>
    <welcome-file>index.jsf</welcome-file>
</welcome-file-list>

Does work, but you'll need Tomcat 7.

Another approach which also works with Tomcat 6 is adding a file called index.jsp with the following contents:

<jsp:forward page="/index.jsf"/>
查看更多
手持菜刀,她持情操
3楼-- · 2020-02-12 14:37

Just rename <welcome-file> entry of index.xhtml to index.jsf and create an empty index.jsf file next to index.xhtml to fool the container that the file actually exist.

Alternatively, you can also just get rid of the .jsf extension altogether and use .xhtml all the way. This can be done by changing <url-pattern> of FacesServlet from *.jsf to *.xhtml.

查看更多
登录 后发表回答