如何显示默认主页?

use*_*434 4 jsf-2

我们的应用程序JSF2/weblogic10.3.4在根上下文中部署了不同的客户端文件夹,如下所示.

app->webapp->ClientA->index.jsf
           ->ClientB->index.jsf
Run Code Online (Sandbox Code Playgroud)

如果用户使用客户端名称请求我们的应用程序,我们需要显示相应的index.jsf.

如果浏览器请求是http:// server/ClientA,我们应该显示http://server/ClientA/index.jsf

如果浏览器请求是http:// server/ClientB,我们应该显示http://server/ClientB/index.jsf

我们怎样才能做到这一点?

Bal*_*usC 7

登记为<welcome-file>web.xml.

<welcome-file-list>
    <welcome-file>index.jsf</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)

您只需要index.xhtml在同一文件夹中的现有文件旁边创建具有该名称的空文件,以便容器被欺骗,这些文件确实存在,否则您仍将获得404.

另一种方法是替换by 的FacesServletURL模式,这样您就不需要使用虚拟URL.*.jsf*.xhtml

...
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
Run Code Online (Sandbox Code Playgroud)