英文:
struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. - [unknown location]
问题
>struts2,无法执行操作:/newAction。没有为操作名称newAction映射的操作。 - [位置未知]
目录和错误信息
![目录和错误信息][1]
以下是文件内容,我不知道为什么会这样。拜托了,我快要疯了。
<%--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>
[1]: https://i.stack.imgur.com/2y4Eh.png
英文:
>struts2,Could not execute action: /newAction There is no Action mapped for action name newAction. - [unknown location]
Directory and error information
Files are as follows, I do not know why it will be like that. Please, I am almost mad.
<%--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>
答案1
得分: 0
查看“入门”文档中的struts.xml部分。
Struts 2配置文件的默认名称是struts.xml
。
英文:
See the struts.xml section of the "Getting Started" docs.
The default name of the Struts 2 configuration file is struts.xml
.
专注分享java语言的经验与见解,让所有开发者获益!
评论