天乙论坛v8 web.xml 分析

  1. <?xmlversion="1.0"encoding="UTF-8"?>
  2. <!--
  3. http://www.ibm.com/developerworks/cn/java/j-tomcat/
  4. 应该指定它们为web.xml文件内<web-app>标记的子标记。
  5. -->
  6. <web-appversion="2.4"
  7. xmlns="http://java.sun.com/xml/ns/j2ee"
  8. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  9. xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  10. <display-name>bbscs8</display-name>
  11. <filter>
  12. <filter-name>UrlRewriteFilter</filter-name>
  13. <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  14. </filter>
  15. <!--
  16. <filter-mapping>标记代表了一个过滤器的映射,
  17. 指定了过滤器会对其产生作用的URL的子集。
  18. 它必须有一个<filter-name>子元素与能找到
  19. 您希望映射的过滤器的过滤器定义相对应。
  20. -->
  21. <filter-mapping>
  22. <filter-name>UrlRewriteFilter</filter-name>
  23. <url-pattern>/*</url-pattern>
  24. </filter-mapping>
  25. <!--
  26. <filter>
  27. <filter-name>SidFilter</filter-name>
  28. <filter-class>com.laoer.bbscs.web.servlet.SidFilter</filter-class>
  29. </filter>
  30. <filter-mapping>
  31. <filter-name>SidFilter</filter-name>
  32. <url-pattern>/*</url-pattern>
  33. </filter-mapping>
  34. -->
  35. <filter>
  36. <filter-name>CharacterEncodingFilter</filter-name>
  37. <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
  38. <!--
  39. init-param>子元素为过滤器实例提供初始化参数
  40. -->
  41. <init-param>
  42. <param-name>encoding</param-name>
  43. <param-value>UTF-8</param-value>
  44. </init-param>
  45. <init-param>
  46. <param-name>forceEncoding</param-name>
  47. <param-value>true</param-value>
  48. </init-param>
  49. </filter>
  50. <filter-mapping>
  51. <filter-name>CharacterEncodingFilter</filter-name>
  52. <url-pattern>/*</url-pattern>
  53. </filter-mapping>
  54. <!--
  55. 如果应用中使用了OpenSessionInViewFilter或者OpenSessionInViewInterceptor,
  56. 所有打开的session会被保存在一个线程变量里。在线程退出前通过
  57. OpenSessionInViewFilter或者OpenSessionInViewInterceptor断开这些session。
  58. 为什么这么做?这主要是为了实现Hibernate的延迟加载功能。基于一个请求
  59. 一个hibernatesession的原则。
  60. -->
  61. <filter>
  62. <filter-name>OpenSessionInViewFilter</filter-name>
  63. <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
  64. </filter>
  65. <filter-mapping>
  66. <filter-name>OpenSessionInViewFilter</filter-name>
  67. <url-pattern>/*</url-pattern>
  68. </filter-mapping>
  69. <!--
  70. 在做上传文件的时候,
  71. 要在web.xml中增加ActionContextCleanUp这个filter,
  72. 如果不增加,会发生第一次上传取不到文件的情况
  73. -->
  74. <filter>
  75. <filter-name>struts-cleanup</filter-name>
  76. <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
  77. </filter>
  78. <filter-mapping>
  79. <filter-name>struts-cleanup</filter-name>
  80. <url-pattern>/*</url-pattern>
  81. </filter-mapping>
  82. <!--
  83. 核心控制器:FilterDispatcher。
  84. FilterDispatcher类存在于org.apache.struts2.dispatcher包下,
  85. 它继承了javax.servlet.Filter接口。在应用的web.xml文件中需要配置该控制器,
  86. 用来接收用户所有请求,FilterDispatcher会判断请求是否为*.action模式,
  87. 如果匹配,则FilterDispatcher将请求转发给Struts2.0框架进行处理。
  88. 在web.xml文件中对FilterDispatcher的配置
  89. -->
  90. <filter>
  91. <filter-name>Struts2</filter-name>
  92. <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
  93. </filter>
  94. <filter-mapping>
  95. <filter-name>Struts2</filter-name>
  96. <url-pattern>/*</url-pattern>
  97. <dispatcher>REQUEST</dispatcher>
  98. <dispatcher>FORWARD</dispatcher>
  99. </filter-mapping>
  100. <context-param>
  101. <param-name>urlrewrite</param-name>
  102. <param-value>false</param-value>
  103. </context-param>
  104. <context-param>
  105. <param-name>cluster</param-name>
  106. <param-value>false</param-value>
  107. </context-param>
  108. <context-param>
  109. <param-name>servletmapping</param-name>
  110. <param-value>*.bbscs</param-value>
  111. </context-param>
  112. <context-param>
  113. <param-name>poststoragemode</param-name>
  114. <param-value>1</param-value>
  115. </context-param>
  116. <listener>
  117. <listener-class>com.laoer.bbscs.web.servlet.SysListener</listener-class>
  118. </listener>
  119. <context-param>
  120. <!--contextConfigLocation参数定义了要装入的Spring配置文件。-->
  121. <param-name>contextConfigLocation</param-name>
  122. <param-value>/WEB-INF/applicationContext.xml,/WEB-INF/action-servlet.xml</param-value>
  123. </context-param>
  124. <!--
  125. 有两种方法,一个是用ContextLoaderListener这个Listerner,
  126. 另一个是ContextLoaderServlet这个Servlet,
  127. 这两个方法都是在web应用启动的时候来初始化WebApplicationContext,
  128. 我个人认为Listerner要比Servlet更好一些,
  129. 因为Listerner监听应用的启动和结束,而Servlet得启动要稍微延迟一些,
  130. 如果在这时要做一些业务的操作,启动的前后顺序是有影响的。
  131. ContextLoader是一个工具类,用来初始化WebApplicationContext,
  132. 其主要方法就是initWebApplicationContext,
  133. 我们继续追踪initWebApplicationContext这个方法
  134. (具体代码我不贴出,大家可以看Spring中的源码),
  135. 我们发现,原来ContextLoader是把WebApplicationContext
  136. (XmlWebApplicationContext是默认实现类)放在了ServletContext中,
  137. ServletContext也是一个“容器”,
  138. 也是一个类似Map的结构,
  139. 而WebApplicationContext在ServletContext中的
  140. KEY就是WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
  141. 我们如果要使用WebApplicationContext则需要从ServletContext取出,
  142. Spring提供了一个WebApplicationContextUtils类,
  143. 可以方便的取出WebApplicationContext,只要把ServletContext传入就可以了。
  144. -->
  145. <listener>
  146. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  147. </listener>
  148. <servlet>
  149. <servlet-name>authimg</servlet-name>
  150. <servlet-class>com.laoer.bbscs.web.servlet.AuthImg</servlet-class>
  151. </servlet>
  152. <servlet-mapping>
  153. <servlet-name>authimg</servlet-name>
  154. <url-pattern>/authimg</url-pattern>
  155. </servlet-mapping>
  156. <servlet>
  157. <servlet-name>rss</servlet-name>
  158. <servlet-class>com.laoer.bbscs.web.servlet.Rss</servlet-class>
  159. </servlet>
  160. <servlet-mapping>
  161. <servlet-name>rss</servlet-name>
  162. <url-pattern>/rss</url-pattern>
  163. </servlet-mapping>
  164. <welcome-file-list>
  165. <welcome-file>index.jsp</welcome-file>
  166. </welcome-file-list>
  167. <!--
  168. 在Tomcat5.0.x中,Tomcat支持了JSP2.0的规格,
  169. 同时也支持了部分J2EE1.4的规格,
  170. 在J2EE1.4的规格中,
  171. 有关JSP的部份,有一个<jsp-config>的XMLTag,
  172. 这个XML区块用来定义与JSP相关的特殊属性,
  173. 包含采用的taglib与以下说明的<jsp-property-group>
  174. 而解决include档中文问题的方法就定义在<jsp-roperty-group>
  175. -->
  176. <jsp-config>
  177. <taglib>
  178. <taglib-uri>/WEB-INF/struts-tags.tld</taglib-uri>
  179. <taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
  180. </taglib>
  181. </jsp-config>
  182. <error-page>
  183. <error-code>401</error-code>
  184. <location>/401.htm</location>
  185. </error-page>
  186. <error-page>
  187. <error-code>403</error-code>
  188. <location>/403.htm</location>
  189. </error-page>
  190. <error-page>
  191. <error-code>404</error-code>
  192. <location>/404.htm</location>
  193. </error-page>
  194. <error-page>
  195. <error-code>500</error-code>
  196. <location>/500.htm</location>
  197. </error-page>
  198. <error-page>
  199. <exception-type>java.lang.NullPointerException</exception-type>
  200. <location>/npe.htm</location>
  201. </error-page>
  202. </web-app>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值