当前位置: 代码迷 >> Java Web开发 >> No result defined for action com.mon.action.LoginAction and result studentSucces,该怎么处理
  详细解决方案

No result defined for action com.mon.action.LoginAction and result studentSucces,该怎么处理

热度:1245   发布时间:2016-04-10 23:32:56.0
No result defined for action com.mon.action.LoginAction and result studentSucces
发现无论是success 还是 input 还是其他的都 不能够返回到struts.xml中

public String execute() throws Exception {
// TODO Auto-generated method stub
System.out.println(userId);
if ("学生".equals(role)) {
StudentDao studentDao=new StudentDaoImpl();
Student student =studentDao.findStudentByID(userId);
if(student == null){
System.out.println("不存在该用户");
addActionError("不存在该用户");
return this.INPUT;
}else{
if(password.equals(student.getPassword())){
Map session=ActionContext.getContext().getSession();
session.put("studentInfo", student);
return "studentSuccess";
}else {
addActionError("密码错误");
return this.INPUT;
}
}
}else{
TeacherDao teacherDao=new TeacherDaoImpl();
Teacher teacher=teacherDao.findTeacherByID(userId);
if(teacher == null){
addActionError("不存在该用户");
return this.INPUT;
}else{
if(password.equals(teacher.getPassword())){
Map session=ActionContext.getContext().getSession();
session.put("teacherInfo", teacher);
return "teacherSuccess";
}else {
addActionError("密码错误");
return this.INPUT;
}
}
}

}


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<constant name="struts.i18n.encoding" value="gb2312"></constant>
<package name="struts2" extends="struts-default">
<action name="login" class="com.mon.action.LoginAction">
<result name="studentSuccess" type="chain">getRandomSubject</result>
  <result name="teacherSuccess" type="redirect">/teacher/index.html</result>
  <result name="INPUT">/index.jsp</result>
</action>
<action name="getRandomSubject" class="com.mon.action.GetRandomSubjectAction">
<result name="SUCCESS">/student/main.jsp</result>
</action>
</package>
</struts>    

------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

<result name="SUCCESS">/student/main.jsp</result>

name属性区分大小写

jsp路径配置是否正确?



<body>
<div class='signup_container'>
    <h1 class='signup_title'>用户登陆</h1>
    <img src='images/people.png' id='admin'/>
    <div id="signup_forms" class="signup_forms clearfix">
            <form class="signup_form_form" id="signup_form" method="post" name="form" action="login.action" data-secure-action="https://www.tumblr.com/login" data-secure-ajax-action="">
                    <div class="form_row first_row">
                        <label for="signup_email">请输入用户名</label><div class='tip ok'></div>
                        <input type="text" name="userId" placeholder="请输入用户名" id="signup_name" data-required="required">
                    </div>
                    <div class="form_row">
                        <label for="signup_password">请输入密码</label><div class='tip ok'></div>
                        <input type="password" name="password" placeholder="请输入密码" id="signup_password" data-required="required">
  相关解决方案