在开始研究这个架构时候,首先查看项目的web.xml
这里贴出部分代码:特殊部分将用xxxx来替代,不影响具体的分析
<?xml version="1.0" encoding="UTF-8"?>
<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">
<context-param><!--在tomcat下部署两个或多个项目时,web.xml文件中最好定义webAppRootKey参数,如果不定义,将会缺省为“webapp.root”,该项 配置是用于log4j的,log能将日志写到对应的根目录下-->
<param-name>webAppRootKey</param-name>
<param-value>xxxx</param-value>
</context-param>
<context-param><!--创建者是spring,不过这个属性值的具体讲解未能搜索到更多详细资料 --> <param-name>creator</param-name>
<param-value>spring</param-value>
</context-param>
<context-param><!--配置spring,让spring默认加载以applicationContext开头的所有xml文件,通过该属性加载所有的配置好的bean --> <param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/applicationContext*.xml
</param-value>
</context-param>
<context-param><!--在spring的帮助下配置log4j,由Sprng载入的Log4j配置文件位置-->
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/Log4j.properties</param-value>
</context-param>
<filter><!--struts2的配置--> <filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping><!--拦截所有.do结尾的请求--> <filter-name>struts2</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>
<filter><!--自定义拦截器 --> <filter-name>AddHeaderFilter</filter-name>
<filter-class>
com.xxxx.core.component.filter.AddHeaderFilter
</filter-class>
<init-param>
<param-name>headers</param-name>
<param-value>Content-Encoding=gzip</param-value>
</init-param>
</filter>
<filter-mapping><!--同理,所有.gzjs的请求都被该拦截器拦截 --> <filter-name>AddHeaderFilter</filter-name>
<url-pattern>*.gzjs</url-pattern>
</filter-mapping>
<listener><!--spring项目中log4j的配置 -->
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener><!--spring的配置 --> <listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener><!--自定义的监听器,看完后用于初始化log4j和常量以及一些常用对象 --> <listener-class>
com.xxxx.core.web.listener.ApplictionInitDataListener
</listener-class>
</listener>
<!-- 后台启动 -->
<listener><自定义的统一管理service的类>
<listener-class>
com.xxxx.xxxxservice.listener.ServiceStartUp
</listener-class>
</listener>
<listener><自定义的管理创建和销毁session的类> <listener-class>
com.xxxx.core.web.listener.SessionListener
</listener-class>
</listener>
<listener><自定义的当用户请求初始化时候的处理类>
<listener-class>
com.xxxx.core.web.listener.RequestListener
</listener-class>
</listener>
<!-- Spring启动入口,不管怎么样都得加载 -->
<servlet>
<servlet-name>DataMessageService</servlet-name>
<servlet-class>
com.xxxx.core.webservice.servlet.MainServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DataMessageService</servlet-name>
<url-pattern>/DataMessageService</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JsonDatamessageService</servlet-name>
<servlet-class>
com.xxxx.core.webservice.servlet.JsonMainServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>JsonDatamessageService</servlet-name>
<url-pattern>/JsonDatamessageService</url-pattern>
</servlet-mapping>
<!-- MESSAGE begin -->
<servlet>
<servlet-name>MessageServlet</servlet-name>
<servlet-class>
com.xxxx.message.servlet.MessageServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>pollAndCometEnabled</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
<!-- MESSAGE end -->
<session-config><!-- session 超时设定 -->
<session-timeout>3600000</session-timeout>
</session-config>
<!-- WebServer 服务配置
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
-->
<filter>
<filter-name>SessionFilter</filter-name>
<filter-class>
com.xxxx.rbac.filter.SessionFilter
</filter-class>
<init-param>
<param-name>logonStrings</param-name>
<param-value>index.jsp;login.do;login.jsp</param-value>
</init-param>
<init-param>
<param-name>includeStrings</param-name>
<param-value>.jsp;.html;.do</param-value>
</init-param>
<init-param>
<param-name>redirectPath</param-name>
<param-value>/application/login/login.jsp</param-value>
</init-param>
<init-param>
<param-name>disabletestfilter</param-name>
<param-value>Y</param-value> </init-param>
</filter>
<filter-mapping>
<filter-name>SessionFilter</filter-name>
<url-pattern>/application/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>application/login/login.jsp</welcome-file>
</welcome-file-list>
</web-app>