HTTP Status 404 - There is no Action mapped for namespace [/] and action name [userAction!add] assoc

来源:互联网 发布:什么是aso优化 编辑:程序博客网 时间:2024/04/30 08:06
在struts2开发中,动态Action处理,因为自己是新手,总是遇到如下问题

HTTP Status 404 - There is no Action mapped for namespace [/] and action name [userAction!add] associated with context path [/Struts2].

网上查询,很多人都说是 如下几种错误:

1,struts.xml文件名错误。一定要注意拼写问题;
2,struts.xml文件放置路径错误。一定要将此文件放置在src目录下。编译成功后,要确认是否编译到classes目录中;
3,struts.xml文件内容错误。struts2.xml配置时拼写有错等
4,看看web.xml中是否对跳转的jsp文件都配置了。

    我仔细检查,并没有出现错误。后来经过多方查找资料后来发现因为我此处是有!(叹号)做动态Action处理,所以需要在struts2中配置<constant name="struts.enable.DynamicMethodInvocation" value="true"></constant>。如图:

配置完这一条后,问题顺利解决了,虽然这是一个比较简单的问题,但是作为新手也是忙活了半个晚上,不过问题解决了还是很高心的。

0 0
原创粉丝点击