在struts 2中找不到资源错误

时间:2018-07-05 07:19:07

标签: struts2

我正在尝试使用struts执行基本的Web应用程序,但是我没有找到资源错误,甚至连index.jsp文件也无法显示。我该怎么办?

下面是我的web.xml文件

web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
    http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"                 
    version="3.1">
    <display-name>Struts2Starter</display-name>
      <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <filter>
    <filter-name>sturts2</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>

下面是我的struts.xml文件

struts.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts  
    Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"> 

    <struts>
    <package name="default" namespace = "/tutorials" extends="struts-default">      
         <action name="getTutorial" class = "com.struts.TutoralAction" >             
            <result name = "success">/success.jsp</result>
            <result name = "failure">/failure.jsp</result>
            </action>
     </package>
     </struts> 

下面是我的动作课

TutorialAction.java

     package com.struts;

      import com.struts.service.TutorialService;

      public class TutoralAction {
       private String bestTutorial;
       public String execute() {
        TutorialService tutorialService = new TutorialService();
         setBestTutorial(tutorialService.getBestTutorial());
         return "success";
           }
       public String getBestTutorial() {
         return bestTutorial;
        }
         public void setBestTutorial(String bestTutorial) {
            this.bestTutorial = bestTutorial;
            }
          }

0 个答案:

没有答案