<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
.......
</web-app>
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>myweb</display-name><!--站點名稱--> <description>這裏是站點描述</description> <icon> <small-icon>/images/small.gif</small-icon><!--小圖標的路徑16*16,必須爲gif jpge格式--> <large-icon>/images/large.gif</large-icon><!--大圖標的路徑32*32,必須爲gif jpge格式--> </icon> <!--如果存在<distributable/>則代表該站點能在多個JSP Container之間分散執行(分佈式)--> <distributable/> <context-param><!--環境參數,設置常量,取得常量 this.getInitParameter("context");--> <param-name>context</param-name> <param-value>10000</param-value> </context-param> <filter><!--聲明filter--> <filter-name>filterName</filter-name> <filter-class>filter.filterName</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping><!--定義filter所對應的URL--> <filter-name>filterName</filter-name> <url-pattern>/filterName</url-pattern> <dispatcher>REQUEST|INCLUDE|FORWARD|ERROR</dispatcher><!--filter對應的請求方式,有4種方式,默認REQUEST--> </filter-mapping> <listener><!--設定Listener接口--> <listener-class>listener.ListenerClassName</listener-class> </listener> <servlet><!--聲明servlet的數據--> <servlet-name>servletName</servlet-name> <servlet-class>servlet.servletName</servlet-class> <init-param><!--初始化參數,可以在init()中使用ServletConfig().getInitParamenter("name")取得--> <param-name>name</param-name> <param-value>123</param-value> </init-param> <load-on-startup>n</load-on-startup><!--站點啓動時,此servlet會被自動加載執行,1表示最早,2,3...--> </servlet> <servlet-mapping><!--定義servlet所對應的URL--> <servlet-name>name</servlet-name> <url-pattern>/name</url-pattern> </servlet-mapping> <session-config><!--設置session超時時間(20分鐘)默認按服務器配置--> <session-timeout>20</session-timeout> </session-config> <mime-mapping><!--定義某個擴展名和某個MIME Type做映射--> <extension>doc</extension> <mime-type>application/vnd.ms-word</mime-type> </mime-mapping> <welcome-file-list><!--設置首頁列表--> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <error-page><!--將錯誤代碼對應到WEB站點的資源路徑--> <error-code>錯誤代碼</error-code>Exception <location>/路徑/</location> </error-page> <error-page><!--將異常的種類對應到WEB站點的資源路徑--> <exception-type>Exception</exception-type> <location>/路徑/</location> </error-page> <jsp-config><!--JSP的相關配置--> <taglib><!--JSP所用到的Tag Library--> <taglib-uri>URI</taglib-uri> <taglib-location>/WEB-INF/lib/xxx.tld</taglib-location> </taglib> <jsp-property-group> <description>此設定的說明</description> <display-name>Name</display-name> <url-pattern>URL</url-pattern><!--此設定影響的範圍--> <el-ignored>true|false</el-ignored><!--true表示不支持EL語法--> <scripting-invalid>encoding</scripting-invalid><!--jsp的編碼--> <include-coda>...jspf</include-coda><!--JSP的結尾,擴展名.jspf--> </jsp-property-group> </jsp-config> <resource-ref><!--利用JNDI取得站點可利用的資源--> <description>資源說明</description> <res-ref-name>資源名稱</res-ref-name> <res-type>資源種類</res-type> <res-auth>Application|Container</res-auth><!--資源經由什麼許可--> <res-sharing-scope>Shareable|Unshareable</res-sharing-scope><!--資源是否可以共享,默認爲Shareable--> </resource-ref> </web-app>