struts2.5框架使用通配符无效问题

错误:

Struts has detected an unhandled exception: 

Messages: There is no Action mapped for namespace [/person] and action name [update] associated with context path [/struts2_04]. 
 

  解决方法:

    不知道从哪个版本开始,action中添加了 allowed-methods 标签,所以要想让对应Action类中的方法能进行匹配,还需要在 allowed-methods 标签注册该方法才行,比如Action中有 saveUser 和 updateUser 方法,配置如下:

		<action name="*" class="com.shawn.action.UserAction" method="{1}User">
			<result name="success">/{1}User.jsp</result>
			<allowed-methods>saveUser,updateUser</allowed-methods>
		</action>

  

总结:struts 2.5 使用通配符调用方法时,内部会验证是否允许访问该方法,所以要加上

<allowed-methods>方法名1,方法名2…</allowed-methods>代码。

posted @ 2017-09-07 17:41  流年如水烟雨随风  阅读(392)  评论(0编辑  收藏  举报