struts2.3.15升级到2.5.13

<p>

struts2.3.15升级到2.5.13

1 、下载 jar struts2.5.13 所有的 jar 包从官网下载的 https://struts.apache.org/index.html   最新的 jar包https://struts.apache.org/download.cgi#struts2513

[struts-2.5.13-all-zip[PGP][MD5]]
2 、替换项目中所有 struts 开头的 jar 包(一般替换所有版本较低的包,高版本一般不替换),删除 xwork-core-2.3.15.1.jar (在 struts2.5.13 版本中,这个包已经被整合,避免冲突删除旧包)
3 、修改 web.xml

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

修改成

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

2.5.13 版本中, StrutsPrepareAndExecuteFilter 的位置变动
4 struts2 配置修改
Struts.xml 头部修改

<?xml version="1.0" encoding=""

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
 "http://struts.apache.org/dtds/struts-2.5.dtd">

头部信息中 struts 的版本修改为 2.5
可能出现的报错:
org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException:  org.apache.struts2.json.JSONException: org.apache.struts2.json.JSONException:    .apache.struts2.json.JSONException: java.lang.reflect.InvocationTargetException  
这是因为 struts2.5  为了提升安全性,添加了 allomethod 属性设置。
解决方法是在配置文件中添加:
<package name="exam" extends="json-default">
    <global-allowed-methods>regex:.*</global-allowed-methods>
<action name="user" class="userAction">
        ...
</action>
</package>
或者在配置文件中添加:

<constantname="struts.enable.DynamicMethodInvocation"value="true"></constant>

目前两种方法都测试有效。
5 struts2 页面修改
页面报错:、Struts has detected an unhandled exception:
Messages:    
/tagDef/export_record_now.jsp (line: 41, column: 4) Attribute id invalid for tag iterator according to 
TLD
File:    org/apache/jasper/compiler/DefaultErrorHandler.java

页面中:jstl标签中的变量id要修改为var

</p>
 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值