Struct2.1.*升级到2.5.13文档

Struct2.1-Struct2.5.10版本存在重要的安全漏洞,所以我们需要升级到2.5.13版本,

升级方法如下:

1.需要删除的jar包

2.需要增加的jar包

3.替换structs.xml

位置:config/structs.xml

修改内容:

a.  头部改为(这个是用来指定文件中允许使用那些标签

b. 关键地方 struts2.5 为了提升安全性,添加了 allomethod 标签

c.由于新版本的Struts默认不能修改action的访问后缀,不能使用通配的方式调用action里的方法,所以添加

使得<constant name="struts.action.extension" value="do" />可以生效

d. 

 注意这里添加了:strict-method-invocation="false"( action标签method属性开启)

4.替换web.xml

位置:WebContent/WEB-INFO/web.xml

修改内容:

<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>修改成

<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>”

原因:新版本的filter包前面没有ng包

5.在config目录下添加log4j2.xml

原因:

log4j 2.x版本不再支持像1.x中的.properties后缀的文件配置方式,2.x版本配置文件后缀名只能为".xml",".json"或者".jsn".所以我们把之前log4j.properties配置信息迁移到新的log4j2.xml中。

详细配置文件节点解析说明请参考:https://www.cnblogs.com/hafiz/p/6170702.html

6.在src\ICT\framework\web.struts2包下替换XssInterceptor.java

原因: 
Apache官方修改了invocation.getInvocationContext().getParameters();接口的实现,原来返回的是一个java.util.Map,现在返回了一个org.apache.struts2.dispatcher.HttpParameters类型的对象

注:页面提交表单的时候不要用struts自带的<s:form>和<s:form>的namespace属性,最好也别用$("#").submit()提交,会出现action无论返回success还是其它的,页面就是不不变,也不是404和500,页面就是不动。解决办法舍弃用<s:form>,直接用普通的<form></form>表单

猜你喜欢

转载自my.oschina.net/u/3577079/blog/1581010