页面提交后就没有反应,
感觉哪边都对的,请高手帮忙解决下
以下是DispatchAction的部署
<action
      attribute="studentForm"
      input="/addStudent.jsp"
      name="studentForm"
      parameter="method"
      path="/admin"
      scope="request"
      type="com.struts.action.AdminStudentAction" />我的Action是这样写的,
public ActionForward addStudent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
StudentForm studentForm = (StudentForm) form;
Student student = new Student();
StudentService service = new StudentServiceImpl();
try{
student.setName(studentForm.getName());
student.setLoginName(studentForm.getLoginName());
student.setPassword(studentForm.getLoginPwd());
student.setSex(studentForm.getSex());
student.setSchool(studentForm.getSchool());
student.setPhone(studentForm.getPhone());
student.setEmail(studentForm.getEmail());
service.addStudent(student); }catch(Exception ex){
ex.printStackTrace();
}
return mapping.findForward("addStudent");
}
jsp如下<%@ page contentType="text/html; charset=gb2312" %>
<%@ taglib uri="/struts-bean" prefix="bean" %>
<%@ taglib uri="/struts-html" prefix="html" %>
<html>
<head>
<title>后台管理</title>
<link href="CSS/stylesheet.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: lightgrey;
}
-->
</style>
</head>
<body>
<html:form action="/admin.do?method=addStudent">
  <table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr height="40">
        <td colspan="2" class="itemTitle" align="center">增加学生</td>
      </tr>
      <tr height="30">
        <td width="160" align="right">学生姓名:</td>
        <td><html:text property="name" size="41" styleClass="textBox"/></td>
     </tr>
      <tr height="30">
        <td valign="top"  align="right">登录名:</td>
        <td><html:text property="loginName" size="41" styleClass="textBox"/></td>
     </tr>
      <tr height="30">
        <td valign="top"  align="right">登录密码:</td>
        <td><html:text property="loginPwd" size="41" styleClass="textBox"/></td>
     </tr>
      <tr height="30">
        <td valign="top"  align="right">所属学院:</td>
        <td><html:text property="school" size="41" styleClass="textBox"/></td>
     </tr>      
      <tr height="30">
        <td colspan="2" align="center">
<html:reset>重置</html:reset>
<html:submit>提交</html:submit>
</td>
     </tr>
    </table>
</html:form>
</body>
</html>

解决方案 »

  1.   

    在配置文件中,加一<forward:name="addStudent" path="所有跳的文件的路径"/>
    或者是return new ActionForward("所有跳的文件的路径");
    即可
      

  2.   

    页面提交后就没有反应----〉
    程序有跳到addStudent方法里面执行吗?
      

  3.   

    <action
          attribute="studentForm"
          input="/addStudent.jsp"
          name="studentForm"
          parameter="method"
          path="/admin"
          scope="request"
          type="com.struts.action.AdminStudentAction">   <forward:name="addStudent" path="/XXX.jsp"/>     --对应你的程序中的:  return mapping.findForward("addStudent");    
    </action>
      

  4.   

    似乎Action都没有执行,不知道怎么回事啊
      

  5.   

    <html:form action="/admin.do?method=addStudent"><html:form action="/admin.do?method=addStudent" method="post">
    加上这个,我以前忘记加,结果死活不行,后来加了METHOD="POST"就可以了
      

  6.   

    你的action是继承自DispatchAction,做了addStudent的method  map映射吗
      

  7.   

    addStudent的method  map是指什么?我没有做
      

  8.   

    把你这个action的代码全部贴出来看看~
      

  9.   


    public class AdminStudentAction extends DispatchAction {
    public ActionForward addStudent(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    StudentForm studentForm = (StudentForm) form;
    Student student = new Student();
    StudentService service = new StudentServiceImpl();
    try{
    student.setName(studentForm.getName());
    student.setLoginName(studentForm.getLoginName());
    student.setPassword(studentForm.getLoginPwd());
    student.setSex(studentForm.getSex());
    student.setSchool(studentForm.getSchool());
    student.setPhone(studentForm.getPhone());
    student.setEmail(studentForm.getEmail());
    service.addStudent(student); }catch(Exception ex){
    ex.printStackTrace();
    }
    return mapping.findForward("addStudent");
    }
    }
      

  10.   

    用EventDispatchAction吧,这个简单点
    EventDispatchAction其实就是从DispatchAction 继承过来的代码这样写
    public class AdminStudentAction extends EventDispatchAction{
    public ActionForward addStudent(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response) {
            StudentForm studentForm = (StudentForm) form;
            Student student = new Student();
            StudentService service = new StudentServiceImpl();
            try{
                student.setName(studentForm.getName());
                student.setLoginName(studentForm.getLoginName());
                student.setPassword(studentForm.getLoginPwd());
                student.setSex(studentForm.getSex());
                student.setSchool(studentForm.getSchool());
                student.setPhone(studentForm.getPhone());
                student.setEmail(studentForm.getEmail());
                service.addStudent(student);        }catch(Exception ex){
                ex.printStackTrace();
            }        
            return mapping.findForward("addStudent");    
        }
    }配置:
    <action
          attribute="studentForm"
          input="/addStudent.jsp"
          name="studentForm"
          parameter="addStudent"
          path="/admin"
          scope="request"
          type="com.struts.action.AdminStudentAction" />
    jsp里面
    <html:submit property="addStudent" value="提交"/>注意:
    submit的property和struts-config.xml里面parameter="addStudent"对应和action类里面方法名字对应就行点提交按钮
      

  11.   

    到底有没有进action方法呢 ?打个断点看看撒。