java - struts2,Could not execute action: /newAction 没有为动作名称newAction映射的动作。- [未知位置]
问题描述
struts2,Could not execute action: /newAction 没有为动作名称newAction映射的动作。- [未知位置]
目录和错误信息
文件如下,不知道为什么会这样。拜托,我快疯了。
<%--new.jsp--%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<title>new.jsp</title>
</head>
<body>
new
<s:action name="newAction"/>
</body>
</html>
<%-- a.jsp--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
a
</body>
</html>
<%!--struts2.xml--%>
<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<constant name="struts.devMode" value="true"/>
<package name="homework6" extends="struts-default">
<action name="newAction" class="homework6.action.NewAction">
<result name="success">/a.jsp</result>
</action>
</package>
</struts>
//NewAction
package homework6.action;
import com.opensymphony.xwork2.ActionSupport;
public class NewAction extends ActionSupport {
@Override
public String execute() throws Exception {
return SUCCESS;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>default</display-name>
<welcome-file-list>
<welcome-file>new.jsp</welcome-file>
<welcome-file>a.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
解决方案
请参阅“入门”文档的struts.xml 部分。
Struts 2 配置文件的默认名称是struts.xml
.
推荐阅读
- html - 如何从带有角度的html制作弹出/视图功能
- python - 为什么即使使用 ResNet、Batchnorm、ReLU,我也会遇到爆炸性的 grad 问题?(张量流)
- android - 如何从 Android 向 Google Assistant 发送命令
- swift - 如何让用户上传不同尺寸的照片?
- reporting-services - SSRS 布局与报表生成器不同
- android - 将本机写入反应到短信而不发送它
- node.js - npm 命令未在请求中发送授权令牌 - 无法进行身份验证
- php - Wordpress - If 语句功能 - 多种帖子类型
- javascript - 我正在尝试在我的列表 ID 中循环并从我的猫鼬数据库中获取它们
- java - 关于 BIM 服务器的安装问题。如何解决 java.lang.NullPointerException: null?