關於Struts2漏洞引發的問題我就不詳細細說了,最近在各大網站及論壇上都有描述,上面都列出了具體的解決辦法對策,對我來講,恰好遇到有現實的案例去解決,在參考了各大論壇、博客的文檔以後作下總結,從Struts2.0.11升級到Struts2.3.15的經歷,之間看了不少的博客,大概花了半天的時間,基本解決了問題。廢話很少說直接來操做吧。 java
首先確定要升級struts2的版本,官方2.3.15.1版本下載struts2.3.15.1地址,具體下載地址:http://mirrors.hust.edu.cn/apache//struts/binaries/struts-2.3.15.1-all.zip web
下載以後,須要用到以下幾個jar包: ajax
commons-fileupload-1.3.jar spring
commons-io-2.0.1.jar apache
commons-lang3-3.1.jar json
freemarker-2.3.19.jar(替換) jsp
javassist-3.11.0.GA.jar(新增) 測試
ognl-3.0.6.jar(替換) 網站
struts2-core-2.3.15.1.jar(替換) spa
struts2-dojo-plugin-2.3.15.1.jar
struts2-json-plugin-2.3.15.1.jar
struts2-junit-plugin-2.3.15.1.jar
struts2-spring-plugin-2.3.15.1.jar(替換)
xwork-core-2.3.15.1.jar(替換)
升級包以後啓動應用會拋出異常,緣由在於struts2.0.x版本用有用到redirect時候,在struts2.3.15.1後result已經改變了,具體改換以下:
<result name="xxx" type="redirect-action">
改爲
<result name="xxx" type="redirectAction">
改動後,再次啓動,在console日誌裏能夠看到會有使用的過時聲明,如:
ActionContextCleanUp <<< is deprecated! Please use the new filters!
在升級以後FilterDispatcher、ActionContextCleanUp已經不建議使用了,具體的解決辦法是在web.xml中改下struts配置:
原來:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
改爲:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
再次改了以後再啓動,已經能夠啓動整個應用,可是具體的時候過程當中,仍是會遇到問題,我所碰到的是主要是兩個問題:
一、原來使用struts2標籤,在jsp頁面上用靜態方法時如@com.xx@xxx()時,這種頁面會有異常,具體的解決辦法以下:
在struts2文件中引入:
<constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant>
二、使用到<s:optiontransferselect ...標籤時沒法在action中取到選中的數據,具體解決辦法,更新下optiontransferselect.js文件,文件在附件中,而且將原來jsp文件中引入以下標籤:
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
,將原來<s:head ajax="head"... 改爲 <sx:head/>
解決了這兩個問題後,基本我就沒發現有其餘的問題,測試完成,具體的測試辦法,可參考各類struts2漏洞的博客,裏面有更詳細的描述,我這裏只講一下解決辦法,但願能給碼友們提供參考。