小编use*_*111的帖子

Struts2 - 请求的资源不可用

有人请帮我执行这个第一个Struts2应用程序.

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_3_0.xsd" id="WebApp_ID" version="3.0">
    <display-name>Struts2FirstProject</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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
       </filter>

       <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
        </filter-mapping>

     </web-app>
Run Code Online (Sandbox Code Playgroud)

Struts.xml文件:

    <?xml version="1.0" encoding="UTF-8"?>

    <struts>

    <package name="default" extends="struts-default">
        <action name="getHello" class="anvi.Hello">
            <result name="success">/success.jsp</result>
            <result name="fail">/error.jsp</result>
        </action>
    </package>

    </struts>
Run Code Online (Sandbox Code Playgroud)

anvi.hello:

    package anvi;

    public class Hello {
    public String execute(){
        System.out.println("Hello from execute");
        return "success";

    }
    }
Run Code Online (Sandbox Code Playgroud)

控制台是:

    9 Nov, 2012 6:16:54 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: The APR based Apache Tomcat Native library which …
Run Code Online (Sandbox Code Playgroud)

struts2 http-status-code-404

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

http-status-code-404 ×1

struts2 ×1