1. <?xml version="1.0" encoding="UTF-8"?>
2.
3. <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">
4.
5. <display-name>網站名稱</display-name>
6. <description>網站描述</description>
7.
8. <!-- icon元素包含small-icon和large-icon兩個子元素.用來指定web站臺中小圖標和大圖標的路徑. -->
9. <icon>
10. <!--small-icon元素應指向web站臺中某個小圖標的路徑,大小爲16 X 16 pixel,但是圖象文件必須爲GIF或JPEG格式,擴展名必須爲:.gif或.jpg. -->
11. <small-icon>路徑/small.gif</small-icon>
12. <!--large-icon元素應指向web站臺中某個大圖表路徑,大小爲32 X 32 pixel,但是圖象文件必須爲GIF或JPEG的格式,擴展名必須爲; gif或jpg.-->
13. <large-icon>路徑/large.jpg</large-icon>
14. </icon>
15.
16. <!-- 配置集羣的時候,要用到,在這篇文章:“apache+tomcat集羣、負載均衡及session複製”裏的第三條(http://jiajun.iteye.com/admin/blogs/278586) -->
17. <distributable/>
18.
19. <!-- context-param 元素用來設定web站臺的環境參數(context),它包含兩個子元素:param-name和param-value.,如spring的典型配置 -->
20. <context-param>
21. <!-- 設定Context名稱 -->
22. <param-name>contextConfigLocation</param-name>
23. <!-- 設定Context名稱的值 -->
24. <param-value>/WEB-INF/spring-config.xml</param-value>
25. </context-param>
26. <!-- 備註:此所設定的參數,在JSP網頁中可以使用下列方法來取得:${initParam.param_name}
27. 若在Servlet可以使用下列方法來獲得:String param_name=getServletContext().getInitParamter("param_name");
28. -->
29.
30. <!-- filter元素用來聲明filter的相關設定.filter元素除了下面介紹的的子元素之外,還包括下面<servlet>紹過的<icon>,<display-name>,<description>,<init-param>,其用途一樣.-->
31. <filter>
32. <!-- 定義Filter的名稱. -->
33. <filter-name>URIFilter</filter-name>
34. <!-- 定義Filter的類名稱 -->
35. <filter-class>org.cjj.filter.URIFilter</filter-class>
36. <init-param>
37. <param-name>encoding</param-name>
38. <param-value>UTF-8</param-value>
39. </init-param>
40. </filter>
41. <!-- filter-mapping 元素的兩個主要子元素filter-name和url-pattern.用來定義Filter所對應的URL.和下面的servlet-mapping一樣 -->
42. <filter-mapping>
43. <!-- 定義Filter的名稱,和上面定義的Filter名稱要一致 -->
44. <filter-name>URIFilter</filter-name>
45. <!-- ilter所對應的RUL,這裏是所有的URL -->
46. <url-pattern>/*</url-pattern>
47. </filter-mapping>
48.
49. <!-- 這裏配置和上面的Filter配置一樣 -->
50. <servlet>
51. <description><![CDATA[Application Setup]]></description>
52. <servlet-name>HTML Action Servlet</servlet-name>
53. <servlet-class>org.cjj.servlet.ActionServlet</servlet-class>
54. <init-param>
55. <param-name>config</param-name>
56. <param-value>/WEB-INF/struts-config.xml</param-value>
57. </init-param>
58. <init-param>
59. <param-name>debug</param-name>
60. <param-value>2</param-value>
61. </init-param>
62. <init-param>
63. <param-name>detail</param-name>
64. <param-value>2</param-value>
65. </init-param>
66. <load-on-startup>0</load-on-startup>
67. </servlet>
68. <!-- 和上面的filter-mapping,一樣 -->
69. <servlet-mapping>
70. <servlet-name>HTML Action Servlet</servlet-name>
71. <url-pattern>*.do</url-pattern>
72. </servlet-mapping>
73.
74. <!-- listener元素用來定義Listener接口,它的主要子元素爲<listener-class> -->
75. <listener>
76. <!-- ServletContextListener接口的實現,監聽Content -->
77. <listener-class>org.cjj.listener.ContextListener</listener-class>
78. </listener>
79. <listener>
80. <!-- HttpSessionListener, HttpSessionAttributeListener接口的實現,監聽session -->
81. <listener-class>org.cjj.listener.SessionListener</listener-class>
82. </listener>
83.
84. <!-- session-config包含一個子元素session-timeout.定義web站臺中的session參數. -->
85. <session-config>
86. <!-- 定義這個web站臺所有session的有效期限.單位爲分鐘. 例子中爲600分鐘 -->
87. <session-timeout>600</session-timeout>
88. </session-config>
89.
90. <!-- mime-mapping包含兩個子元素extension和mime-type.定義某一個擴展名和某一MIME Type做對映. -->
91. <mime-mapping>
92. <!-- 擴展名稱 -->
93. <extension>htm</extension>
94. <!-- MIME格式 -->
95. <mime-type>text/html</mime-type>
96. </mime-mapping>
97. <mime-mapping>
98. <extension>flv</extension>
99. <mime-type>video/x-flv</mime-type>
100. </mime-mapping>
101. <mime-mapping>
102. <extension>doc</extension>
103. <mime-type>application/vnd.ms-word</mime-type>
104. </mime-mapping>
105. <mime-mapping>
106. <extension>xls</extension>
107. <mime-type>application/vnd.ms-excel</mime-type>
108. </mime-mapping>
109.
110. <!-- welcome-file-list包含子元素welcome-file,用來定義首頁列單,如: -->
111. <welcome-file-list>
112. <welcome-file>index.jsp</welcome-file>
113. <welcome-file>index.html</welcome-file>
114. </welcome-file-list>
115.
116. <!-- error-page元素包含三個子元素error-code,exception-type和location.將錯誤代碼(Error Code)或異常(Exception)的種類對應到web站臺資源路徑.-->
117. <error-page>
118. <!-- HTTP Error code -->
119. <error-code>403</error-code>
120. <!-- 在web站點內的相關資源路徑 -->
121. <location>路徑/403.jsp</location>
122. </error-page>
123. <error-page>
124. <error-code>404</error-code>
125. <location>路徑/404.jsp</location>
126. </error-page>
127. <error-page>
128. <error-code>500</error-code>
129. <location>路徑/500.jsp</location>
130. </error-page>
131. <error-page>
132. <!-- 一個完整名稱的Java異常類型 -->
133. <exception-type>java.lang.Exception</exception-type>
134. <location>路徑/exception.jsp</location>
135. </error-page>
136.
137. <!-- jsp-config元素主要用來設定JSP的相關配置,<jsp:config>包括<taglib>和<jsp-property-group>兩個子元素.
138. 其中<taglib>元素在JSP 1.2時就已經存在了;而<jsp-property-group>是JSP 2.0新增的元素.
139. -->
140. <jsp-config>
141. <!-- taglib元素包含兩個子元素taglib-uri和taglib-location.用來設定JSP網頁用到的Tag Library路徑. -->
142. <taglib>
143. <!-- 定義TLD文件的URI,JSP網頁的taglib指令可以經由這個URI存取到TLD文件. -->
144. <taglib-uri>core</taglib-uri>
145. <!-- TLD文件對應Web站臺的存放位置. -->
146. <taglib-location>/WEB-INF/tld/jstl-1-core.tld</taglib-location>
147. </taglib>
148. <taglib>
149. <taglib-uri>bean</taglib-uri>
150. <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
151. </taglib>
152. <taglib>
153. <taglib-uri>html</taglib-uri>
154. <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location>
155. </taglib>
156. <taglib>
157. <taglib-uri>logic</taglib-uri>
158. <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location>
159. </taglib>
160. <taglib>
161. <taglib-uri>tiles</taglib-uri>
162. <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
163. </taglib>
164. <!-- jsp-property-group元素包含8個元素 -->
165. <jsp-property-group>
166. <!-- 此設定的說明 -->
167. <description>Special property group for JSP Configuration JSP example.</description>
168. <!-- 此設定的名稱 -->
169. <display-name>JSPConfiguration</display-name>
170. <!-- 設定值所影響的範圍,如:/CH2 或者/*.jsp -->
171. <uri-pattern>/*</uri-pattern>
172. <!-- 若爲true,表示不支持EL語法. -->
173. <el-ignored>true</el-ignored>
174. <!-- 若爲true表示不支持<%scription%>語法. -->
175. <scripting-invalid>false</scripting-invalid>
176. <!-- 設置JSP網頁的擡頭,擴展名爲.jspf -->
177. <include-prelude>.jspf</include-prelude>
178. <!-- 設置JSP網頁的結尾,擴展名爲.jspf -->
179. <include-coda>.jspf</include-coda>
180. <!-- 編碼 -->
181. <page-encoding>utf-8</page-encoding>
182. </jsp-property-group>
183. </jsp-config>
184.
185. <!-- esource-ref元素包括五個子元素description,res-ref-name,res-type,res-auth,res-sharing-scope.利用JNDI取得站臺可 -->
186. <resource-ref>
187. <!-- 資源說明 -->
188. <description>JNDI JDBC DataSource of JSPBook</description>
189. <!-- 資源名稱 -->
190. <res-ref-name>jdbc/sample_db</res-ref-name>
191. <!-- 資源種類 -->
192. <res-type>javax.sql.DataSoruce</res-type>
193. <!-- 資源由Application或Container來許可,如下面爲Container -->
194. <res-auth>Container</res-auth>
195. <!-- 資源是否可以共享.默認值爲 Shareable 可選擇Shareable|Unshareable -->
196. <res-sharing-scope>Unshareable</res-sharing-scope>
197. </resource-ref>
198.
199.</web-app>