我是Struts的新手,我想执行HelloWorld程序,但是一旦我在web.xml
中写入<filter>
标记,我就会收到“请求的资源不可用”错误。Struts 2中没有的资源
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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
struts.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<package name="helloworld" extends="struts-default">
<action name="hello" class="sagar.practice.HelloWorldAction" method="execute">
<result name="success">/HelloWorld.jsp</result>
</action>
</package>
</struts>
我添加了所有必需的支柱瓶当用户库。
我访问索引页为:http://localhost:8080/practice/index.jsp
如果我删除<filter>
标签从web.xml
文件我能够访问index.jsp
页,但如果我添加<filter>
标签这是给“请求的资源不可用”错误。
index.jsp是在WEB-INF下?相同的HelloWorld.jsp? –