There is no Action mapped for namespace [/] and action name [Login] associated w

打代码的苏比特 2017-11-30 10:22:45
求助
There is no Action mapped for namespace [/] and action name [Login] associated with context path [].
我是用IDEA写的struts2项目,项目运行后报错如上。
这是我的struts配置文件struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
"http://struts.apache.org/dtds/struts-2.5.dtd">
<struts>
<package name="struts2" extends="struts-default" namespace="/">
<action name="Login" class="com.guet.action.LoginAction" method="execute">
<result name="teacherSuccess" type="redirect">/teacher/index.html</result><!--老师登录成功页面-->
</action>
</package>

这是对应的Action类

package com.guet.action;
import com.opensymphony.xwork2.ActionSupport;
/**
* 用于进行登陆校验
*/
public class LoginAction extends ActionSupport {
private String id; // 接受用户编号
private String password; // 接受用户密码
private String role; // 接受用户角色

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

@Override
public String execute() throws Exception {
System.out.println("执行了Action方法");
System.out.println("id"+id+"password"+password+"role"+role);
return "teacherSuccess";
}
}

这个是jsp页面表单部分代码
<s:form name="myform" action="Login" method="post" namespace="/">
<table cellSpacing="0" cellPadding="0" width="100%" border="0" height="143" id="table212">
<tr>
<td colspan="2"><font color="red"><s:actionerror/></font></td><!--显示错误信息 -->
</tr>
<tr>
<td width="14%" height="38" class="top_hui_text"><span class="login_txt">编号:   </span></td>
<td height="38" colspan="2" class="top_hui_text"><input name="id" class="editbox4" value="" size="20"> </td>
</tr>
<tr>
<td width="14%" height="35" class="top_hui_text"><span class="login_txt"> 密 码:    </span></td>
<td height="35" colspan="2" class="top_hui_text"><input class="editbox4" type="password" size="20" name="password">
<img src="teacher/images/luck.gif" width="19" height="18"> </td>
</tr>
<tr>
<td width="14%" height="35" ><span class="login_txt">登录角色:</span></td>
<td height="35" colspan="2" class="login_txt"><input type="radio" name="role" value="teacher" checked="checked">教师
<input type="radio" name="role" value="student">学生</td>
</tr>
<tr>
<td height="35" > </td>
<td width="19%" height="35" ><input name="Submit" type="submit" class="button" id="Submit" value="登 录"> </td>
<td width="67%" class="top_hui_text"><input name="cs" type="button" class="button" id="cs" value="取 消" onClick="showConfirmMsg1()"></td>
</tr>
</table>
<br>
</s:form></td>

已经检查过了,编译之后的struts.xml在WEB-INF文件夹的classes文件夹下,如下图


恳请各位大佬帮助
...全文
387 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_1797801363 2018-12-26
  • 打赏
  • 举报
回复
动态方法调用设置为true
  • 打赏
  • 举报
回复
anybody here?
  • 打赏
  • 举报
回复
顶一下顶一下
  • 打赏
  • 举报
回复
先回去睡觉,明天再来看bug

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧