困扰好久找不到原因
最后看到一篇文章才解决
当你觉得web.xml过滤器没问题
struts.xml写的action也没有问题
jsp页面写的访问地址也没有问题
但就是~~404~~ 时
可能是你设置了调试模式查看值栈没有关掉注释
<constantname="struts.devMode" value="true"></constant>
如果在struts.xml里配置了以上常量,即设置为调试模式
那么此项目部署在服务器中时,是访问不到页面的
只需要注释以上代码,或者更改成运行模式,就能正常访问到页面
至于为什么我也不清楚,正在研究中,如有发现,后续将更新
struts2 最主要过滤器配置顺便放上:
<!-- Struts2配置过滤器-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
本文介绍了一种在Struts2框架中常见的404问题,当项目处于调试模式时,即使web.xml过滤器、struts.xml及JSP页面无误,也可能因struts.devMode设置为true而导致页面无法访问。解决方法是注释或更改为运行模式。

1088

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



