1、Spring上下文ApplicationContext.xml的加载:
注意:classpath:spring-countext.xml里面的:spring-countext.xml是你自己所创建的spring上下文
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-countext.xml</param-value>
</context-param>
2、 启动Web容器时,自动装配ApplicationContext.xml的配置信息:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
3、整合Struts2
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
4、添加中文乱码过滤器:
<!--3、添加过滤器 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<async-supported>true</async-supported>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
5、其他配置:(一般不用):
5-1 防止内存泄露、缓存清除监听器:
<listener>
<listener-class>
org.springframework.web.util.IntrospectorCleanupListener
</listener-class>
</listener>
5-2:用于支持3种Bean的作用域:request,session和globalSession
<listener-class> org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
5-3:把session的关闭延迟到jsp页面显示之后,请配在struts2上面
<filter>
<filter-name>OpenSessionInView</filter-name>
<filter-class> org.springframework.orm.hibernate5.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInView</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>