web.xml,在welcome-file-list中具有不同的文件 [英] web.xml with different files in welcome-file-list

查看:119
本文介绍了web.xml,在welcome-file-list中具有不同的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用JSF,我有点迷路了.我正在开发JSF应用程序,我有两个输入点.

i'm starting to use JSF and I'm a bit lost. I'm developping a JSF application and I have two enter points.

有时候,我需要使用浏览器来打开名为mydata.xhtml的页面,而有时候,我需要打开名为dataexchange.xhtml的页面.

Some times I need my browser to open a page named mydata.xhtml and another times I need to open a page named dataexchange.xhtml.

现在我已经完成了第一个,该应用程序运行正常.我想我必须更改我的web.xml文件,不是吗?

Now I have done the first one, and the application works fine. I think I have to change my web.xml file, isn`t it?

我的 web.xml 是这个.

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/mydata.xhtml</welcome-file>
    </welcome-file-list>
</web-app></pre>

推荐答案

我认为web.xml中没有if-else逻辑选项

I dont think there is an option of if-else logic in web.xml

   <welcome-file-list>
        <welcome-file>faces/mydata.xhtml</welcome-file>
        <welcome-file>faces/dataexchange.xhtml</welcome-file>
    </welcome-file-list>

如果将上述两个文件都放入欢迎文件列表中,则容器将首先搜索mydata.xhtml,并且只有在找不到时,容器才会搜索并返回dataexchange.

If you put both the files in welcome file list as above, the container will first search for mydata.xhtml and only if not found, will the container search and return dataexchange.

或者,您可以拥有DispatcherServlet(

Alternatively, you can have a DispatcherServlet (

Either some framework provided or custom servlet with load on startup 1

) 并从servlet中返回您想要的xhtml.

) and from the servlet you can return the xhtml you want to.

这篇关于web.xml,在welcome-file-list中具有不同的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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