1.项目运行后,可以进入index.jsp页面,但是访问调用action时浏览器报404异常
后台报错:
There is no Action mapped for namespace [/] and action name [test] associated with context path [/Struts2_demo01]. - [unknown location] at com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:185)
问题原因:
解决办法:
1.struts.xml文件应该配置在src下,修改后即可
2.因为Struts2 要求 strust.xml 文件显示在classes的文件夹里,所以我们要在WebContent/WEB-INF/classes 的文件夹下创建 struts.xml 文件, Eclipse并没有默认创建“classes”文件夹,因此你需要自己创建
Struts2访问Action异常404
本文解决了一个常见的Struts2问题:项目启动后访问Action时出现404错误。通过调整struts.xml配置文件的位置,确保其正确放置在项目的classes目录下,从而解决了该问题。
314

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



