如何设置JSF2< welcome-file>与面孔的servlet映射? [英] How to set JSF2 <welcome-file> with faces servlet mapping?

查看:91
本文介绍了如何设置JSF2< welcome-file>与面孔的servlet映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Facelets的简单JSF2应用程序.我的web.xml设置如下:-

I have a simple JSF2 app using Facelets. My web.xml is set as follows:-

<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping> 

我想将应用程序默认设置为/pages/login.xhtml的欢迎页面.当进入浏览器的上下文根目录时,我似乎无法获得欢迎文件"设置来接听此文件.

I want to set the app to default to the welcome page which is /pages/login.xhtml. I can't seem to get the welcome-file setting to pick up this when going to the context root in the browser.

我的web.xml欢迎设置如下:-

My web.xml welcome setting is as follows:-

<welcome-file-list>
<welcome-file>/pages/login.jsf</welcome-file>
</welcome-file-list>

如何强制欢迎页面进入登录页面并确保其通过Faces Servlet?

How do I force the welcome-page to goto the login page and ensure it goes through the faces servlet?

如果我使用以下内容,则会显示该页面,但该页面尚未通过Faces Servlet,因此没有呈现Faces组件:-

If I use the following the page displays but it hasn't gone through the faces servlet and so faces components aren't rendered:-

<welcome-file-list>
<welcome-file>pages/login.xhtml</welcome-file>
</welcome-file-list>

任何帮助表示赞赏!

推荐答案

您必须创建一个与login.xhtml文件相邻的空login.jsf文件.出于某种原因,需要使用此技巧来诱使Servlet容器认为您的欢迎文件存在.

You have to create an empty login.jsf file, adjacent to your login.xhtml file. For some reason this hack is needed to trick the servlet container into thinking your welcome file exists.

注意:所提供的响应仍将是使用您的login.xhtml文件而不是您创建的空login.jsf文件的JSF响应.

Note: The response served will still be the JSF response using your login.xhtml file, not the empty login.jsf file you create.

这篇关于如何设置JSF2&lt; welcome-file&gt;与面孔的servlet映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆