来源:http://blog.csdn.net/iyandong/article/details/52792471
1、需要引入jar包数量的变化
在之前的版本中需要单独引入xwork-core-2.x.x.jar,在2.5.2版本中该jar包已经整合到struts2-core-2.5.x.jar 找不到的同学不需要再引入啦。
2、web.xml配置filter-class的改变
下面是2.5.2的版本
- <filter>
- <filter-name>struts2</filter-name>
- <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
- </filter>
3、关于使用通配符调用无效的问题
参考文章:http://blog.csdn.net/qq_24059599/article/details/51986761
新学习的同学按照一些视频上,原来2.3的样子写出代码来,在运行的时候会报错,错误如下。
- Struts Problem Report
-
- Struts has detected an unhandled exception:
-
- Messages:
- There is no Action mapped for namespace [/actions] and action name [Studentadd] associated with context path [].
原来在struts2.5 中为了增加安全性,在 struts.xml 添加了这么个属性:<global-allowed-methods>regex:.*</global-allowed-methods>,添加完成之后就可以正常运行通配符的配置了。
- <struts>
- <constant name="struts.devMode" value="true"></constant>
- <package name="actions" extends="struts-default" namespace="/actions">
-
- <global-allowed-methods>regex:.*</global-allowed-methods>
-
- <action name="Student*" class="com.action.method.dmi.StudentAction" method="{1}">
- <result>/Student{1}_success.jsp</result>
- </action>
-
- <action name="*_*_success" class="com.action.method.dmi.{1}Action" method="{2}">
- <result>/{1}_{2}_success.jsp</result>
- </action>
- </package>
- </struts>