记录一次错误——关于Struts2的package使用

在一个demo中,我把struts.xml分成每个包下一个(分为struts1.xml、struts2.xml、struts3.xml),然后用struts.xml把这些分文件include起来。在每次写的时候,都是直接复制粘贴然后修改。

当使用struts3.xml时,出现问题了,无法找到我配置的action。查原因,也是运气好,乱试了几下就被我碰到了。

原来我忘记修改package标签中的name属性了。在听课的时候老师说这个那么随意起什么,所以修改时就没有注意他,导致struts1.xml和struts3.xml中的package的name属性都为demo1。这就导致了无法找到struts3.xml配置的action(struts1.xml配置的action仍然可以找到)。

错误提示为:

HTTP Status 404 – Not Found


Type Status Report

Message There is no Action mapped for namespace [/] and action name [requestDemo1] associated with context path [/struts2].

Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.


Apache Tomcat/7.0.94

发布了43 篇原创文章 · 获赞 17 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/Hitmi_/article/details/102606785