Struts2.0因安全漏洞升级到2.3的操作手册和遇到的有关问题

Struts2.0因安全漏洞升级到2.3的操作手册和遇到的问题
版本升级原因:struts2.0漏洞
[url]http://struts.apache.org/download.cgi#struts221
[/url]
[url]
http://struts.apache.org/release/2.3.x/docs/s2-014.html[/url]

升级方法和问题:
https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=30743764
http://bbs.csdn.net/topics/390598510


Step 1 - 更新Struts 2的jar文件到Class Path
【Struts2.0的jar依赖包】
asm.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.14.jar
xwork-2.0.7.jar
commons-lang-2.5.jar(保留)

【Struts2.3的jar依赖包】
工具:maven、jar_search等
我们添加Struts 2最小需求的jar包。我们将把这些jar包拷贝到WEB-INF\lib这个文件夹中。
找到并拷贝这些文件
asm-3.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
commons-lang3-3.1.jar
freemarker-2.3.19.jar
ognl-3.0.6.jar
struts2-core-2.3.16.3.jar
xwork-core-2.3.16.3.jar


Step 2 - 更新Struts 2 Servlet Filter
【truts2.0的servlet过滤器】
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
      <url-pattern>*.jsp</url-pattern>
      <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
</filter-mapping>

【struts2.3的servlet过滤器】
为了要Struts 2 框架在你的web应用中工作,你需要在web.xml文件中添加Servlet Filter类和Filter mappingr。下面是你要添加的内容。
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



Step 3 - 创建struts.xml文件
【打开DMI】
2.3+默认DMI是关闭的,动态方法调用官方推荐的做法是,使用通配符的形式,因可能存在安全隐患:
<constant name="struts.enable.DynamicMethodInvocation" value="true" />

否则总是跳转到default action execute中或报错:TTP Status 404 - There is no Action mapped for namespace [/] and action name [login!login.action] associated with context path [/]