01.AP部署描述(web.xml)






在專案中登錄 Faces Servlet 引用


Sample code -1


<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

  xmlns="http://java.sun.com/xml/ns/javaee"

  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 

      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"

  version="2.5">

  <servlet>

    <servlet-name>Faces Servlet</servlet-name>

    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

  </servlet>

  <servlet-mapping>

    <servlet-name>Faces Servlet</servlet-name>

    <url-pattern>/faces/*</url-pattern>

    <url-pattern>*.jsf</url-pattern>

        <url-pattern>*.jsf</url-pattern>

        <url-pattern>*.aspx2</url-pattern>

        <url-pattern>*.php</url-pattern>

  </servlet-mapping>

  <context-param>

    <param-name>javax.faces.PROJECT_STAGE</param-name>

    <param-value>Development</param-value>

 </context-param>

  <welcome-file-list>

    <welcome-file>index.jsp</welcome-file>

    <welcome-file>index.html</welcome-file>

  </welcome-file-list>

</web-app>




Sample code - 2


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
    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_3_0.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>
<!-- default: *.xhtml -->
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>faces/index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>


javax.faces.PROJECT_STAGE


javax.faces.application.ProjectStage provides the following options:

  • Production 
  • Development
  • UnitTest
  • SystemTest
  • Extension


  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <listener>
    <listener-class>com.sun.faces.config.ConfigureListener</listener-class>
  </listener>



目前richfaces3.3.3cr1版還不能支持JSF2內置的faceslet,所以在web.xml文件中設置參數,關閉faceslet,

具體參數如下:

Java代碼 
  1. <context-param>  
  2.     <description>不使用JSF2內置的facelet視圖處理器</description>  
  3.     <param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>  
  4.     <param-value>true</param-value>  
  5. </context-param>  


引用第三方JSF UI集


參考 引用 Primefaces

Subpages (1): Sample-Purge
Comments