update.jsp
<%@page import="com.jaovo.msg.model.User"%>
<%@page import="com.jaovo.msg.Util.DaoFactory"%>
<%@page import="com.jaovo.msg.dao.IUserDao"%>
<%@page import="com.jaovo.msg.Util.ValidateUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
//获取客户端传递过来的参数
int id = Integer.parseInt(request.getParameter("id"));
String time = request.getParameter("time");
String jieci = request.getParameter("jieci");
String college = request.getParameter("college");
String tid = request.getParameter("tid");
String tname = request.getParameter("tname");
String number = request.getParameter("number");
boolean validate = ValidateUtil.validateNull(request, new String[]{"age","major"});
if(!validate){
%>
<jsp:forward page="updateInput.jsp"></jsp:forward>
<%
}
IUserDao userDao = DaoFactory.getDaoImpl();
User user = userDao.load(id);
user.setTime(time);
user.setJieci(jieci);
user.setCollege(college);
user.setTid(tid);
user.setTname(tname);
user.setNumber(number);
userDao.update(user);
response.sendRedirect("index.jsp");
%>
<%@page import="com.jaovo.msg.Util.DaoFactory"%>
<%@page import="com.jaovo.msg.dao.IUserDao"%>
<%@page import="com.jaovo.msg.Util.ValidateUtil"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
//获取客户端传递过来的参数
int id = Integer.parseInt(request.getParameter("id"));
String time = request.getParameter("time");
String jieci = request.getParameter("jieci");
String college = request.getParameter("college");
String tid = request.getParameter("tid");
String tname = request.getParameter("tname");
String number = request.getParameter("number");
boolean validate = ValidateUtil.validateNull(request, new String[]{"age","major"});
if(!validate){
%>
<jsp:forward page="updateInput.jsp"></jsp:forward>
<%
}
IUserDao userDao = DaoFactory.getDaoImpl();
User user = userDao.load(id);
user.setTime(time);
user.setJieci(jieci);
user.setCollege(college);
user.setTid(tid);
user.setTname(tname);
user.setNumber(number);
userDao.update(user);
response.sendRedirect("index.jsp");
%>
updateInput.jsp
<%@page import="com.jaovo.msg.Util.ValidateUtil"%>
<%@page import="com.jaovo.msg.model.User"%>
<%@page import="com.jaovo.msg.Util.DaoFactory"%>
<%@page import="com.jaovo.msg.dao.IUserDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户修改页面</title>
</head>
<body>
<%
//获取客户端传递过来的参数
int id = Integer.parseInt(request.getParameter("id"));
IUserDao userDao = DaoFactory.getDaoImpl();
User user = userDao.load(id);
%>
<form action="update.jsp" method="get">
<table align="center" border="1" width="500">
<input type="hidden" name="id" value="<%=user.getId() %>" />
<tr>
<td>课程名称 : </td>
<td>
<input type="text" name="name" value="<%=user.getName() %>" />
<%=ValidateUtil.showError(request, "name") %>
</td>
</tr>
<tr>
<td>开课时间:</td>
<td>
<input type="text" name="time" value="<%=user.getTime() %>" />
<%=ValidateUtil.showError(request, "time") %>
</td>
<tr>
<td>开课节次 : </td>
<td>
<input type="text" name="jieci" value="<%=user.getJieci() %>" />
<%=ValidateUtil.showError(request, "jieci") %>
</td>
</tr>
<tr>
<td>所属学院 : </td>
<td>
<input type="text" name="college" value="<%=user.getCollege() %>" />
<%=ValidateUtil.showError(request, "college") %>
</td>
</tr>
<tr>
<td>教师工号 : </td>
<td>
<input type="text" name="tid" value="<%=user.getTid() %>" />
<%=ValidateUtil.showError(request, "tid") %>
</td>
</tr>
<tr>
<td>教师姓名 : </td>
<td>
<input type="text" name="tname" value="<%=user.getTname() %>" />
<%=ValidateUtil.showError(request, "tname") %>
</td>
</tr>
<tr>
<td>限制人数 : </td>
<td>
<input type="text" name="number" value="<%=user.getNumber() %>" />
<%=ValidateUtil.showError(request, "number") %>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</body>
</html>
<%@page import="com.jaovo.msg.model.User"%>
<%@page import="com.jaovo.msg.Util.DaoFactory"%>
<%@page import="com.jaovo.msg.dao.IUserDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>用户修改页面</title>
</head>
<body>
<%
//获取客户端传递过来的参数
int id = Integer.parseInt(request.getParameter("id"));
IUserDao userDao = DaoFactory.getDaoImpl();
User user = userDao.load(id);
%>
<form action="update.jsp" method="get">
<table align="center" border="1" width="500">
<input type="hidden" name="id" value="<%=user.getId() %>" />
<tr>
<td>课程名称 : </td>
<td>
<input type="text" name="name" value="<%=user.getName() %>" />
<%=ValidateUtil.showError(request, "name") %>
</td>
</tr>
<tr>
<td>开课时间:</td>
<td>
<input type="text" name="time" value="<%=user.getTime() %>" />
<%=ValidateUtil.showError(request, "time") %>
</td>
<tr>
<td>开课节次 : </td>
<td>
<input type="text" name="jieci" value="<%=user.getJieci() %>" />
<%=ValidateUtil.showError(request, "jieci") %>
</td>
</tr>
<tr>
<td>所属学院 : </td>
<td>
<input type="text" name="college" value="<%=user.getCollege() %>" />
<%=ValidateUtil.showError(request, "college") %>
</td>
</tr>
<tr>
<td>教师工号 : </td>
<td>
<input type="text" name="tid" value="<%=user.getTid() %>" />
<%=ValidateUtil.showError(request, "tid") %>
</td>
</tr>
<tr>
<td>教师姓名 : </td>
<td>
<input type="text" name="tname" value="<%=user.getTname() %>" />
<%=ValidateUtil.showError(request, "tname") %>
</td>
</tr>
<tr>
<td>限制人数 : </td>
<td>
<input type="text" name="number" value="<%=user.getNumber() %>" />
<%=ValidateUtil.showError(request, "number") %>
</td>
</tr>
<tr align="center">
<td colspan="2">
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</body>
</html>