系统实现规范:以面向接口的方式进行编程。
下图为三层逻辑结构的简易关系图
以上是简易的系统逻辑结构,***Action继承于xwork的SupportAction,通过Spring来进行管理,在整个Spring的容器中,Spring负责管理整个系统的所有Bean,并负责初始化Bean之间的依赖关系。***Action中注入了服务层对象***ServiceImpl,而ServiceImpl又注入了***DaoImpl对象。下面会逐步细化上面的关系图。
先看下面的web.xml配置
web.xml
<display-name>Struts Blank</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>wxy.root</param-value>
</context-param>
<!-- spring xml文件配置目录在class目录下的spring目录中WEB-INF/classes/spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/*.xml</param-value>
</context-param>
<!-- 配置log4j的日志信息WEB-INF/classes/config/log4j.properties -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath*:config/log4j.properties</param-value>
</context-param>
<!-- 配置Character Encoding Filter -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<!-- 配置Struts2 -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<!-- 载入Spring ApplicationContext -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring 刷新Introspector防止内存泄漏 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener>
未完待续.