关于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>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值