jsf web.xml配置
<web-app version="2.5" 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-app_2_5.xsd">
??? <!-- **********JSF参数设置************************************* -->
??? <context-param>
??????? <description>
??????????? 详见:javax.faces.application.ProjectStage类
??????????? 可取值:
??????????????? Development
??????????????? UnitTest
??????????????? SystemTest
??????????????? Production
??????? </description>
??????? <param-name>javax.faces.PROJECT_STAGE</param-name>
??????? <param-value>Development</param-value>
??? </context-param>
??? <context-param>
??????? <description>
??????????? 指示是在客户端(client)还是在服务器端(server)保存UI组件的状态和
??????????? session信息, server表示保存到服务器端,client表示保存到客户端,
??????????? 默认为server。
??????? </description>
??????? <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
??????? <param-value>client</param-value>
??? </context-param>
??? <context-param>
??????? <description>
??????????? 当使用扩展名映射(后缀映射)时,所使用的资源的默认后缀
??????????? 默认为.jsp,它自于javax.faces.application.ViewHandler
??????????? 类中的常量. 常量的名字是 DEFAULT_SUFFIX 值相当于 ".jsp"
??????? </description>
??????? <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
??????? <param-value>.xhtml</param-value>
??? </context-param>
??? <!--
??? <context-param>
??????? <description>
??????????? 当在这个应用中处理JSF请求时,
??????????? 所使用的生命周期实例的标识符.
??????????? 默认的生命周期模型
??????? </description>
??????? <param-name>javax.faces.LIFECYCLE_ID</param-name>
??????? <param-value></param-value>
??? </context-param>
??? -->
??? <!-- ********************************************************* -->
??? <context-param>
??????? <description>
??????????? 逗号分隔的上下文相关的资源路径列表,
??????????? JSF将在装载WEB-INF/faces-config.xml之前载入这些资源
??????? </description>
??????? <param-name>javax.faces.CONFIG_FILES</param-name>
??????? <param-value>
??????????? /WEB-INF/faces-config.xml
??????? </param-value>
??? </context-param>
??? <context-param>
??????? <description>
??????????? 设置自定义的Facelets标签库文件路径
??????? </description>
??????? <param-name>javax.faces.FACELETS_LIBRARIES</param-name>
??????? <param-value>/WEB-INF/guessnumber.taglib.xml</param-value>
??? </context-param>
??? <!-- ********************************************************* -->
??? <context-param>
??????? <description>
??????????? Set this flag to true if you want the JSF
??????????? Reference Implementation to verify that all of the application
??????????? objects you have configured (components, converters,
??????????? renderers, and validators) can be successfully created.
??????????? Default value is false.
??????????? 告诉JSF验证其可以创建应用对象(组件,呈现器,转换器等),
??????????? 那么设置标志为true, 默认值为false。
??????? </description>
??????? <param-name>com.sun.faces.verifyObjects</param-name>
??????? <param-value>false</param-value>
??? </context-param>
??? <context-param>
??????? <description>
??????????? Set this flag to true if you want the JavaServer Faces
??????????? Reference Implementation to validate the XML in your
??????????? faces-config.xml resources against the DTD. Default
??????????? value is false.
??????????? 告诉JSF根据DTD验证配置文件,
??????????? 那么设置标志为true, 默认值为false。
???????? </description>
??????? <param-name>com.sun.faces.validateXml</param-name>
??????? <param-value>false</param-value>
??? </context-param>
??? <!--
??? <context-param>
??????? <description>资源更新检查周期</description>
??????? <param-name>com.sun.faces.resourceUpdateCheckPeriod</param-name>
??????? <param-value>-1</param-value>
??? </context-param>
??? <context-param>
??????? <description>
??????????? 当状态保存方法设置为server时,
??????????? 控制会话中保存的视图数量.
??????????? 无默认值
??????? </description>
??????? <param-name>com.sun.faces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
??????? <param-value>-1</param-value>
??? </context-param>
??? -->
??? <!-- ********************************************************* -->
??? <!--
??? <context-param>
??????? <description>
??????????? Setting this to true will cause the FaceletViewHandler
??????????? to print out debug information in an easy to use screen
??????????? when an error occurs during the rendering process。
??????????? 很显然,为了方便开发,我们应该设置。
??????? </description>
??????? <param-name>facelets.DEVELOPMENT</param-name>
??????? <param-value>true</param-value>
??? </context-param>
??? <context-param>
??????? <param-name>facelets.SKIP_COMMENTS</param-name>
??????? <param-value>true</param-value>
??? </context-param>
??? -->
??? <!-- **********JSF基本设置************************************* -->
??? <!-- Faces Servlet -->
??? <servlet>
??????? <servlet-name>Faces Servlet</servlet-name>
??????? <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
??????? <load-on-startup>1</load-on-startup>
??? </servlet>
??? <!-- Faces Servlet Mapping -->
??? <!--
???????? This mapping identifies a jsp page as having JSF content.? If a
???????? request comes to the server for foo.faces, the container will
???????? send the request to the FacesServlet, which will expect a
???????? corresponding foo.jsp page to exist containing the content.
??? -->
??? <servlet-mapping>
??????? <servlet-name>Faces Servlet</servlet-name>
??????? <url-pattern>*.faces</url-pattern>
??????? <!--
??????? <url-pattern>*.xhtml</url-pattern
??????? <url-pattern>*.jsf</url-pattern>
??????? <url-pattern>/faces/*</url-pattern>
??????? -->
??? </servlet-mapping>
??? <!-- **********Web基本设置************************************ -->
??? <session-config>
??????? <session-timeout>30</session-timeout>
??? </session-config>
??? <welcome-file-list>
??????? <welcome-file>index.html</welcome-file>
??????? <welcome-file>index.jsp</welcome-file>
??????? <welcome-file>index.xhtml</welcome-file>
??? </welcome-file-list>
??? <!-- **********安全设置**************************************** -->
??? <login-config>
??????? <auth-method>FORM</auth-method>
??????? <realm-name/>
??????? <form-login-config>
??????????? <form-login-page>/login.jsp</form-login-page>
??????????? <form-error-page>/loginerror.jsp</form-error-page>
??????? </form-login-config>
??? </login-config>
??? <security-role>
??????? <role-name>manager</role-name>
??? </security-role>
??? <security-role>
??????? <role-name>employee</role-name>
??? </security-role>
??? <security-constraint>
??????? <web-resource-collection>
??????????? <web-resource-name>jsf</web-resource-name>
??????????? <description>javaserver faces</description>
??????????? <url-pattern>/security/*</url-pattern>
??????? </web-resource-collection>
??????? <auth-constraint>
??????????? <role-name>manager</role-name>
??????????? <role-name>employee</role-name>
??????? </auth-constraint>
??? </security-constraint>
</web-app>