困扰两天了,希望能得到帮助,谢谢:There is no Action mapped for namespace
网上的方法都试过了,还是不行,一个小程序都搞不定,连玩游戏的热情都没有了,希望各位哥伸出圆手,小弟感激不胜
我的struts.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="cj" namespace="/" extends="struts-default">
<action name="login" class="org.game.action.LoginAction">
<result name="success">/WEB-INF/content/loginForm.jsp</result>
<result name="error">/WEB-INF/content/succ.jsp</result>
</action>
</package>
<!-- Add packages here -->
</struts>
我的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">
<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>
</web-app>
我的action文件
package org.game.action;
import org.game.domain.Employee;
import com.opensymphony.xwork2.Action;
public class LoginAction implements Action {
private Employee emp;
public void setEmp(Employee emp) {
this.emp = emp;
}
public Employee getEmp() {
return emp;
}
@Override
public String execute() throws Exception {
if("tony".equals(emp.getName()) && "123".equals(emp.getPass()))
{
return SUCCESS;
}
return ERROR;
}
}
普通class
package org.game.domain;
public class Employee {
private String name;
private String pass;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
}
这个是jsp文件:
loginForm.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>添加员工</title>
</head>
<body>
<form action="login" method="post">
员工名:<input type="text" name="emp.name"/><br/>
性别:<input type="text" name="emp.pass"/><br/>
<input type="submit" value="登陆"/>
</form>
</body>
</html>
succ.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"