0
这是我的动作类没有映射为命名空间/和动作名称登录行动
package actions;
import com.opensymphony.xwork2.ActionSupport;
import bean.UserBean;
public class UserInsert extends ActionSupport {
private static final long serialVersionUID = 1L;
public String execute() throws Exception {
return "success";
}
public static void main(String[] org) {
}
}
这里是index.jsp的代码
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Developer</title>
</head>
<body>
<h1>Login Page</h1>
<form action="login">
<table>
<tr>
<td><label>User Name/Email</label></td>
<td><input type="text" /></td>
</tr>
<tr>
<td><label>Password</label></td>
<td><input type="password" /></td>
</tr>
<tr>
<td></td>
<td><button type="submit">Login</button></td>
</tr>
</table>
</form>
</body>
</html>
这里是web.xml中的代码
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Struts Blank</display-name>
<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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
这里是struts.xml代码
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<action name="login" class="actions.UserInsert" method="execute">
<result name="success">/welcome.jsp</result>
</action>
</package>
</struts>
我跟着mkyoung的这个链接“http://www.mkyong.com/struts2/there-is-no-action-mapped-for-namespace-and-action-name-youractionname/”,但得到相同的错误,而“struts.devMode”关闭或“struts.devMode”打开时得到相同的错误“没有操作映射到命名空间/和动作名称登录“ 如果有人遇到过这个问题,请给出您的建议。 我使用JDK 1.8,Apache Tomcat上8
我试过这个,但没有任何运气。 –
经过更多时间的浪费,我改变了我的.jar文件现在我的映射工作,这是因为jar文件不匹配。 :) –