[英]faces-config.xml is config file
By default when we create a web application faces-config.xml
doesnt created automatically. 默认情况下,当我们创建Web应用程序时, faces-config.xml
不会自动创建。 We must create him manually and as I understood faces-config.xml
must be located strictly in WEB-INF
. 我们必须手动创建他,因为我理解faces-config.xml
必须严格地位于WEB-INF
。
So, my question: 所以,我的问题:
Do I have to register faces-config.xml
in web.xml
after creation in WEB-INF
or other folder or is it registered automatically. 在WEB-INF
或其他文件夹中创建后,我是否必须在web.xml
注册faces-config.xml
,或者是否自动注册。 Ie does JSF "know" what is the faces-config.xml
and can find him in all project's folder. 即JSF“知道” faces-config.xml
是什么,可以在所有项目的文件夹中找到他。
Hope, I asked correct question.;) 希望,我问了正确的问题。;)
As taken from FacesServlet
documentation: 取自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. 如果未在web.xml或web-fragment.xml中显式映射此servlet,并且满足以下一个或多个条件,则必须自动映射此servlet。
A faces-config.xml file is found in WEB-INF. 在WEB-INF中可以找到faces-config.xml文件。
A faces-config.xml file is found in the META-INF directory of a jar in the application's classpath. faces-config.xml文件位于应用程序类路径中jar的META-INF目录中。
A filename ending in .faces-config.xml is found in the META-INF directory of a jar in the application's classpath. 以.faces-config.xml结尾的文件名位于应用程序类路径中jar的META-INF目录中。
The javax.faces.CONFIG_FILES context param is declared in web.xml or web-fragment.xml. javax.faces.CONFIG_FILES上下文参数在web.xml或web-fragment.xml中声明。
The Set of classes passed to the onStartup() method of the ServletContainerInitializer implementation is not empty. 传递给ServletContainerInitializer实现的onStartup()方法的类集不为空。
You can put your configuration file elsewhere in your webapp, but you need to keep in mind the following facts: 您可以将配置文件放在webapp中的其他位置,但需要记住以下事实:
WEB-INF
/ META-INF
folders; 您不希望将文件公开为可访问,因此您希望它最终位于WEB-INF
/ META-INF
文件夹下; You need to add the following entry to your web.xml: 您需要将以下条目添加到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>
Otherwise the faces-config.xml is loaded automatically if found in some predefined locations. 否则,如果在某些预定义位置找到faces-config.xml,则会自动加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.