在学习struts2 DMI调用,使用action!method请求时返回404,提示如下:
There is no Action mapped for namespace [/] and action name [user!update] associated with context path [/StrutsTest].
后看到网上说DMI调用默认是关闭的,需要修改变量配置打开。在struts.xml增加
<constant name="struts.enable.DynamicMethodInvocation" value="true" />然后变成了如下提示:Method update for action user is not allowed!最后发现除了要增加上述配置外,还需要在使用DMI调用的包中增加如下配置:<global-allowed-methods>regex:.*</global-allowed-methods>至此,问题解决。
本文介绍了解决Struts2中使用DMI调用时出现404错误的方法。通过配置struts.xml文件启用DMI,并设置允许的方法,最终解决了Method update for action user is not allowed的问题。
553

被折叠的 条评论
为什么被折叠?



