File tree Expand file tree Collapse file tree 5 files changed +45
-6
lines changed
imoocSSHStudentManagementSystem
com/southeast/iLoveMasami Expand file tree Collapse file tree 5 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
118118 <tr >
119119 <td >出生日期:</td >
120120 <td ><input name =" birthday" type =" text" id =" control_date" size =" 20"
121- maxlength =" 10" onclick =" new Calendar().show(this);" readonly = " readonly "
121+ maxlength =" 10" onclick =" new Calendar().show(this);"
122122 value =" <s:date name=" #session.modify_students.birthday " format=" yyyy-MM-dd " />"
123123 />
124124 </td >
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
66<!DOCTYPE html>
77<html >
88 <meta http-equiv =" content-type" content =" text/html;charset=UTF-8" >
9- <link rel =" stylesheet" type =" text/css" href =" .. /css/default.css" />
9+ <link rel =" stylesheet" type =" text/css" href =" <%= path % > /css/default.css" />
1010<style type =" text/css" >
1111* {
1212 background : none repeat scroll 0 0 transparent ;
@@ -79,15 +79,15 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
7979<div id =" navi" >
8080 <!-- 导航空白 -->
8181 <div id =' naviDiv' >
82- <span ><img src =" .. /images/arror.gif" width =" 7" height =" 11" border =" 0" alt =" " ></span >  ; 学生管理<span >  ;
83- <span ><img src =" .. /images/arror.gif" width =" 7" height =" 11" border =" 0" alt =" " ></span >  ; <a href =" <%= path % >/students /Students_query.action" >学生列表</a ><span >  ;
82+ <span ><img src =" <%= path % > /images/arror.gif" width =" 7" height =" 11" border =" 0" alt =" " ></span >  ; 学生管理<span >  ;
83+ <span ><img src =" <%= path % > /images/arror.gif" width =" 7" height =" 11" border =" 0" alt =" " ></span >  ; <a href =" <%= path % > /Students_query.action" >学生列表</a ><span >  ;
8484 </div >
8585</div >
8686<div id =" tips" >
8787 <!-- 导航空白 -->
8888</div >
8989<div id =" mainContainer" >
90- <strong >修改成功,<a href =" <%= path % > /students/ Students_query.action" >返回学生列表</a ></strong >
90+ <strong >修改成功,<a href =" <%= path % > /Students_query.action" >返回学生列表</a ></strong >
9191 <!-- 数据表格空白 -->
9292</div >
9393</body >
Original file line number Diff line number Diff line change @@ -71,4 +71,25 @@ public String modify()
7171 session .setAttribute ("modify_students" , s );
7272 return "modify_success" ;
7373 }
74+ //保存修改的动作
75+ public String save ()
76+ {
77+ StudentsDao sdao = new StudentsDaoImpl ();
78+ Students s = new Students ();
79+ s .setSid (request .getParameter ("sid" ));
80+ s .setSname (request .getParameter ("sname" ));
81+ s .setGender (request .getParameter ("gender" ));
82+ String dateString = request .getParameter ("birthday" );
83+ SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd" );
84+ Date date ;
85+ try {
86+ date = sdf .parse (dateString );
87+ s .setBirthday (date );
88+ } catch (ParseException e ) {
89+ e .printStackTrace ();
90+ }
91+ s .setAddress (request .getParameter ("address" ));
92+ sdao .updateStudents (s );
93+ return "save_success" ;
94+ }
7495}
Original file line number Diff line number Diff line change @@ -92,8 +92,25 @@ public boolean addStudents(Students s) {
9292 @ Override
9393 public boolean updateStudents (Students s ) {
9494
95- return false ;
95+ Transaction tx =null ;
96+ try {
97+ Session session =MyHibernateSessionFactory .getSessionFactory ().getCurrentSession ();
98+ tx =session .beginTransaction ();
99+ session .update (s );
100+ tx .commit ();
101+ return true ;
102+ }
103+ catch (Exception ex ){
104+ ex .printStackTrace ();
105+ tx .commit ();
106+ return false ;
107+ }
108+ finally {
109+ if (tx !=null )
110+ tx =null ;
111+ }
96112 }
113+
97114
98115 @ Override
99116 public boolean deleteStudents (String sid ) {
Original file line number Diff line number Diff line change 2020 <result name =" delete_success" type =" chain" >Students_query</result >
2121 <result name =" add_success" >/jsp/students/Students_add_success.jsp</result >
2222 <result name =" modify_success" >/jsp/students/Students_modify.jsp</result >
23+ <result name =" save_success" >/jsp/students/Students_modify_success.jsp</result >
2324 <result name =" input" >/jsp/students/Students_query_success.jsp</result >
2425
2526 </action >
You can’t perform that action at this time.
0 commit comments