1.加入jar包
复制文件。
复制struts2-spring-plugin-x-x-x.jar和spring.jar到WEB-INF/lib目录下。其中的x对应了Spring的版本号。还需要复制commons-logging.jar、struts2-core-2.3.4.1.jar文件到WEB-INF/lib目录下。
2. 配置web.xml
< xml version="1.0" encoding="UTF-8" >
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">
game.cai
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encoding
utf-8
forceencoding
true
encodingFilter
/*
struts2
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
struts2
/*
org.springframework.web.context.ContextLoaderListener
contextConfigLocation
classpath:/applicationContext*.xml
hibernateOpenSessionInViewFilter
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
struts2CleanUpFilter
org.apache.struts2.dispatcher.ActionContextCleanUp
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
3.添加struts2-spring整合的插件:struts2-spring-plugin-2.0.12.jar,如果不使用这个插件,则需要在struts.xml里面配置:
推荐阅读: