日期:2014-05-17  浏览次数:20687 次

SSH JSP页面跳转UPDATE方法貌似没有用
//daoimpl
public void updateStu(Student stu) throws Exception {
this.getHibernateTemplate().update(stu);

}
//bizimpl
public void updateStu(Student stu) throws Exception {
// TODO Auto-generated method stub
studao.updateStu(stu);
}
//action
public String updateStu()throws Exception{
try {
stubiz.updateStu(stu);
System.out.println(stu.getSid()+stu.getSname()+stu.getSage());
return SUCCESS;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return INPUT;
}

//jsp
 <body>
  <form action="updatestu.action" method="post">  
  <table>  
  <tr>
  <td>姓名:</td>
  <td><input type="text" value="${stu.sname }"></input></td>
  </tr> 
  <tr>
  <td>年龄:</td>
  <td><input type="text" value="${stu.sage }"></input></td>
  </tr>  
  <tr>
  <td>住址:</td>
  <td><input type="text" value="${stu.sadress }"></input></td>
  </tr>  
  <tr>
  <td>联系电话:</td>
  <td><input type="text" value="${stu.sphone }"></input></td>
  </tr>
  <tr>
  <td>所在学校:</td>
  <td><input type="text" value="${stu.school }"></input></td>
  </tr>
  </table>
  <input type="submit" value="更新">
  <input type="button" value="删除" onclick="javascript:location.href='delstu.action?id=${sid}'">
  </form>
  </body>


//struts.xml

 <package name="mintao" extends="struts-default">
  <action name="zw" class="stuaction">
  <result type="redirectAction">getall</result>
  <result name="input">addstu.jsp</result>
  </action>
  <action name="getall" class="stuaction" method="getall">
  <result>showlist.jsp</result>
  <result name="input">addstu.jsp</result>
  </action>
  <action name="delstu" class="stuaction" method="delStudent">
  <result type="redirectAction">getall</result>
  <result name="input">detail.jsp</result>
  </action>
  <action name="/updatestu" class="stuaction" method="updateStu">
  <result type="redirectAction">getall</result>
  <result name="input">detail.jsp</result>
  </action>
  <action name="getstu" class="stuaction" method="getStuById">
  <result>detail.jsp</result>
  <result name="input">showlist.jsp</result>
  </action>
 </package>

目前其他增删查都没有问题,