Skip to content

Commit 3175d6a

Browse files
committed
学生基本功能完成
1 parent 4dc8620 commit 3175d6a

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

imoocSSHStudentManagementSystem/WebRoot/jsp/students/Students_modify.jsp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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>

imoocSSHStudentManagementSystem/WebRoot/jsp/students/Students_modify_success.jsp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff 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>&nbsp;学生管理<span>&nbsp;
83-
<span><img src="../images/arror.gif" width="7" height="11" border="0" alt=""></span>&nbsp;<a href="<%=path%>/students/Students_query.action">学生列表</a><span>&nbsp;
82+
<span><img src="<%=path%>/images/arror.gif" width="7" height="11" border="0" alt=""></span>&nbsp;学生管理<span>&nbsp;
83+
<span><img src="<%=path%>/images/arror.gif" width="7" height="11" border="0" alt=""></span>&nbsp;<a href="<%=path%>/Students_query.action">学生列表</a><span>&nbsp;
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>

imoocSSHStudentManagementSystem/src/com/southeast/iLoveMasami/action/StudentsAction.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

imoocSSHStudentManagementSystem/src/com/southeast/iLoveMasami/serviceimpl/StudentsDaoImpl.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff 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) {

imoocSSHStudentManagementSystem/src/struts.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
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>

0 commit comments

Comments
 (0)