【发布时间】:2014-05-02 09:40:33
【问题描述】:
我正在尝试关注tutorial。我正在使用 Eclipse 和 Tomcat 服务器来运行应用程序。
我的过滤器标签没有被识别,相应的动作文件没有被调用。当我尝试运行应用程序时
http://localhost:8080/Struts2Starter
它只是说"The requested resource is not available"。
我已经下载了相应的 struts2 jar 文件并将它们指向WEB-INF/lib。
我的web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts2Starter</display-name>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
我的struts.xml 位于类路径(src 文件夹)中,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="default" extends="struts-default">
<action name="getTutorial" class="org.kowshik.action.TutorialAction">
<result name="success">/success.jsp</result>
</action>
</package>
</struts>
我真的不确定我错过了什么。
【问题讨论】:
-
在启动过程中或请求时是否有任何错误?
-
没有..我没有收到任何错误..
-
@Sruthi 如果你没有收到任何错误,那么你很好,资源不可用,因为没有这样的资源。要么让 struts 处理资源或 web 服务器。目前没有其他选择,您应该知道这一点。
-
“过滤器标签无法识别”是什么意思?您不需要将调试模式设置为 true,将日志记录设置为调试,并在启动时查看日志。
标签: java eclipse struts2 filter web.xml