我是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? –