关于strut使用通配符调用无效的问题

来源: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的版本

[html]  view plain  copy
  1. <filter>  
  2.     <filter-name>struts2</filter-name>  
  3.     <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>  
  4. </filter>  

3、关于使用通配符调用无效的问题

参考文章:http://blog.csdn.net/qq_24059599/article/details/51986761

新学习的同学按照一些视频上,原来2.3的样子写出代码来,在运行的时候会报错,错误如下。

[html]  view plain  copy
  1. Struts Problem Report  
  2.   
  3. Struts has detected an unhandled exception:  
  4.   
  5. Messages:     
  6. 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>,添加完成之后就可以正常运行通配符的配置了。

[html]  view plain  copy
  1. <struts>  
  2.     <constant name="struts.devMode" value="true"></constant>  
  3.     <package name="actions" extends="struts-default" namespace="/actions">  
  4.           
  5.         <global-allowed-methods>regex:.*</global-allowed-methods>  
  6.           
  7.         <action name="Student*" class="com.action.method.dmi.StudentAction" method="{1}">  
  8.             <result>/Student{1}_success.jsp</result>  
  9.         </action>  
  10.           
  11.         <action name="*_*_success" class="com.action.method.dmi.{1}Action" method="{2}">  
  12.             <result>/{1}_{2}_success.jsp</result>  
  13.         </action>  
  14.     </package>  
  15. </struts>  

猜你喜欢

转载自blog.csdn.net/system_obj/article/details/77727352