我正在按照本教程构建我的第一个Struts2示例.
I am following this tutorial to build my first Struts2 example.
我的项目名称(也包括war文件)为HelloWorld,并且每当我尝试访问时 localhost:8080/HelloWorld/index.jsp我知道
My project name (and war file also) is HelloWorld and whenever I try to access localhost:8080/HelloWorld/index.jsp I get
请求的资源不可用.
The requested resource is not available.
我的war文件在tomcat webapps目录中,并且tomcat运行良好.
I have my war file in tomcat webapps directory and tomcat is running fine.
我要去哪里错了?
推荐答案该教程是旧的.
它仍然使用org.apache.struts2.dispatcher.FilterDispatcher,这是自Struts 2.1.8起已弃用的过滤器.
It still uses org.apache.struts2.dispatcher.FilterDispatcher , that is a deprecated filter since Struts 2.1.8.
您需要使用新的过滤器:org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
You need to use the new filter: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
然后确保在 web.xml 中正确设置了过滤器和过滤器映射:
Then ensure you have both the filter and the filter-mapping correctly set in your 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>更多推荐
Apache Tomcat错误:请求的资源不可用
发布评论