HTTP Status 404 - There is no Action mapped for namespace [/] and action name [Action!Method]错误解决

按照书本上的Struts2的例子,运行会出现错误:

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [sayHelloAction!sayStruts2] ...

 貌似在struts.xml中配置action的method不会出错,而直接在jsp中写“Action!Method.action”就会报错。

搜索许久没有发现解决办法,后来发现第二种写法叫做“DMI”,会产生安全隐患,在struts2的某个版本后就默认关闭了(我使用的是Struts 2-2.3.20)。于是在struts.xml的<struts></struts>中添加下面一行即可:

<constant name="struts.enable.DynamicMethodInvocation" value="true" />

 

posted @ 2015-01-14 19:57  添哥  阅读(3260)  评论(0编辑  收藏  举报