struts2 - struts 2中未找到资源错误
问题描述
我正在尝试使用 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;
}
}
解决方案
推荐阅读
- angularjs - 抽象状态控制器的 $scope 在离开时不会被破坏 - AngularJS
- xamarin.forms - Xam 插件:CrossLocalNotifications.Current.Show 在三星 S8 上不起作用(最新更新后)
- haskell - 斐波那契函数的惰性求值
- android - 带有圆角边缘的按钮动态背景颜色
- excel - 如何将范围设置为活动列?
- python - 我正在使用 scapy 来获取探测信息。我是 python 新手,也是 scapy
- spring-mvc - 如何使用 Spring MVC 在单个 Jasper 报告中查看两个不同的 jasper 报告?
- c# - 实体框架,通过防止左外连接排序
- android - 找不到元素“菜单”的声明
- c# - 如何使用数据网格添加某个值来更新数据库?