struts2官网地址:http://struts.apache.org/
1.下载strtuts2.5包
2.替换工程中的附件目录文件
freemarker-2.3.23.jar
ognl-3.1.2.jar
struts2-core-2.5.10.jar
struts2-json-plugin-2.5.10.jar
struts2-spring-plugin-2.5.10.jar
3.删除原工程“xwork-core-2.3.20.jar”
4.修改web.xml,把“<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>”修改成“<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>”
5.修改jsp的struts标签,新版本里有两处明显区别
a.类似 <s:bean name="com.whb.common.DictItem" id="dictItem" /> 要修改成 <s:bean name="com.whb.common.DictItem" var="dictItem" />
b.类似<s:property value="result" escape="false"/> 要修改成 <s:property value="result" escapeHtml="false"/>
6.修改Struts.xml文件
a.头部改为<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
b.由于新版本的Struts默认不能修改action的访问后缀,不能使用通配的方式调用action里的方法,所以添加
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<constant name="struts.enable.SlashesInActionNames" value="true"/>
使得<constant name="struts.action.extension" value="do" />可以生效
c.<package name="mypackage" namespace="/" extends="struts-default" strict-method-invocation="false"> 注意这里添加了strict-method-invocation="false"