小蜜锋 - 云代码空间
—— 技术宅拯救世界!
CREATE TABLE `user` ( `uId` varchar(16) NOT NULL, `uName` varchar(16) NOT NULL, `uPassword` varchar(32) NOT NULL, `uEmail` varchar(32) NOT NULL, `uIdCard` varchar(20) NOT NULL, `uPhone` varchar(11) NOT NULL, `date` datetime NOT NULL, `status` char(1) NOT NULL, PRIMARY KEY (`uId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
package com.gym.model; public class UserModel { private String uId; private String uName; private String uPassword; private String uEmail; private String uIdCard; private String uPhone; private String date; private String status; public String getuId() { return uId; } public void setuId(String uId) { this.uId = uId; } public String getuName() { return uName; } public void setuName(String uName) { this.uName = uName; } public String getuPassword() { return uPassword; } public void setuPassword(String uPassword) { this.uPassword = uPassword; } public String getuEmail() { return uEmail; } public void setuEmail(String uEmail) { this.uEmail = uEmail; } public String getuIdCard() { return uIdCard; } public void setuIdCard(String uIdCard) { this.uIdCard = uIdCard; } public String getuPhone() { return uPhone; } public void setuPhone(String uPhone) { this.uPhone = uPhone; } public String getDate() { return date; } public void setDate(String date) { this.date = date; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }数据持久层里调用:
resultSet = (ResultSet) statement.executeQuery(sql); while (resultSet.next()) { userModel = new UserModel(); userModel.setDate(resultSet.getString("date")); userModel.setStatus(resultSet.getString("status")); userModel.setuEmail(resultSet.getString("uEmail")); userModel.setuId(resultSet.getString("uId")); userModel.setuIdCard(resultSet.getString("uIdcard")); userModel.setuName(resultSet.getString("uName")); userModel.setuPassword(resultSet.getString("uPassword")); userModel.setuPhone(resultSet.getString("uPhone")); list.add(userModel); }服务层里调用:
UserDaoImpl userDaoImpl = new UserDaoImpl(); if (userDaoImpl.alterUser(userModel) == 1) { return Constant.SUCCESS; } else { return Constant.ERROR; }控制层里调用:
UserModel userModel = userServiceImpl.queryUserInfoById(userId); List userList = new ArrayList(); userList.add(userModel); RequestDispatcher dispatcher = request .getRequestDispatcher("/usercenter/index.jsp"); request.setAttribute("userList", userList); dispatcher.forward(request, response);表现层里调用:
<c:forEach items="${requestScope.userList}" var="list"> <table id="user-info-list" cellspacing="2px"> <tr> <th scope="row">校园卡号:</th> <td> ${list.getuId()} </td> </tr> <tr> <th scope="row">姓名:</th> <td> ${list.getuName()} </td> </tr> <tr> <th scope="row">邮箱:</th> <td> ${list.getuEmail()} </td> </tr> <tr> <th scope="row">手机号码:</th> <td> ${list.getuPhone()}</td> </tr> </table> </c:forEach>