加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

jsf – faces-config.xml是配置文件

发布时间:2020-12-15 23:59:08 所属栏目:百科 来源:网络整理
导读:默认情况下,当我们创建Web应用程序时,faces-config.xml不会自动创建.我们必须手动创建他,因为我理解faces-config.xml必须严格地位于WEB-INF中. 所以,我的问题: 在WEB-INF或其他文件夹中创建后,我是否必须在web.xml中注册faces-config.xml,或者是否自动注册.
默认情况下,当我们创建Web应用程序时,faces-config.xml不会自动创建.我们必须手动创建他,因为我理解faces-config.xml必须严格地位于WEB-INF中.

所以,我的问题:

在WEB-INF或其他文件夹中创建后,我是否必须在web.xml中注册faces-config.xml,或者是否自动注册.即JSF“知道”faces-config.xml是什么,可以在所有项目的文件夹中找到他.

希望,我问了正确的问题.;)

取自 FacesServlet文档:

This servlet must automatically be mapped if it is not explicitly mapped in web.xml or web-fragment.xml and one or more of the following conditions are true.

  • A faces-config.xml file is found in WEB-INF.

  • A faces-config.xml file is found in the META-INF directory of a jar in the application’s classpath.

  • A filename ending in .faces-config.xml is found in the META-INF directory of a jar in the application’s classpath.

  • The javax.faces.CONFIG_FILES context param is declared in web.xml or web-fragment.xml.

  • The Set of classes passed to the onStartup() method of the ServletContainerInitializer implementation is not empty.

您可以将配置文件放在webapp中的其他位置,但需要记住以下事实:

>您不希望将文件公开为可访问,因此您希望它最终位于WEB-INF / META-INF文件夹下;
>您需要将以下条目添加到web.xml:

<context-param>
    <param-name>javax.faces.CONFIG_FILES</param-name>
    <param-value>
        WEB-INF/path/to/faces-config.xml
   </param-value>
</context-param>

否则,如果在某些预定义位置找到faces-config.xml,则会自动加载.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读