What is the use of faces-config.xml in JSF 2?
在JSF 2对注释的大力支持之后,我想知道将
换句话说,只能通过
现在我所使用的只是声明Spring的EL解析器。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <el-resolver> org.springframework.web.jsf.el.SpringBeanFacesELResolver </el-resolver> </application> </faces-config> |
它仍然可以用于许多无法注释的内容。例如。定制JSF验证消息:
1 2 | <message-bundle>com.example.i18n.messages</message-bundle> </application> |
全局i18n捆绑包(这样就不必在每个视图中声明
1 2 3 4 5 | <resource-bundle> <base-name>com.example.i18n.Text</base-name> <var>text</var> </resource-bundle> </application> |
明确支持的i18n语言环境(即使存在消息捆绑包或资源捆绑包,也将忽略未声明的语言环境):
1 2 3 4 5 6 7 | <locale-config> <default-locale>en</default-locale> <supported-locale>nl</supported-locale> <supported-locale>es</supported-locale> <supported-locale>de</supported-locale> </locale-config> </application> |
自定义视图处理程序:
1 2 | <view-handler>com.example.SomeViewHandler</view-handler> </application> |
阶段监听器(仍然没有注释):
1 2 3 | <lifecycle> <phase-listener>com.example.SomePhaseListener</phase-listener> </lifecycle> |
无法注释的托管bean(以下一个给出了
1 2 3 4 5 6 | <managed-bean> <description>Current date and time</description> <managed-bean-name>now</managed-bean-name> <managed-bean-class>java.util.Date</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> |
自定义工厂,例如自定义异常处理程序工厂(它还允许
1 2 3 | <factory> <exception-handler-factory>com.example.SomeExceptionHandlerFactory</exception-handler-factory> </factory> |
仅列出常用名称。如果您的IDE中具有