小编典典

Apache Tomcat错误:请求的资源不可用

jsp

我正在按照本教程来构建我的第一个Struts2示例。

我的项目名称(还有war文件)是HelloWorld,只要我尝试访问,
http://localhost:8080/HelloWorld/index.jsp我都会得到

请求的资源不可用。

我的战争文件在tomcat webapps目录中,并且tomcat运行正常。

我要去哪里错了?


阅读 4741

收藏
2020-06-10

共1个答案

小编典典

该教程是旧的。

从Struts2.1.8开始org.apache.struts2.dispatcher.FilterDispatcher,它仍然使用,这是不推荐使用的过滤器。

您需要使用新的过滤器:
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

然后确保在 web.xml中 正确设置了过滤器和过滤器映射:

<filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
2020-06-10