SSM多表联合查询
来源:互联网 发布:程序员离职证明 编辑:程序博客网 时间:2024/06/01 08:50
jsp:
<table border="1" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA"align="center" style="margin-top: 8px"><tr class="green"><!-- s.id,u.name,s.card_type,s.phone,s.record_date --><th>记录id</th><th>姓名</th><th>持卡类型</th><th>部门名称</th><th>打卡时间</th><th>联系电话</th><th>记录日期</th></tr><c:forEach items="${ swipeRecordList }" var="sw"><tr><td>${sw.id }</td><td>${sw.user.username}</td><td>${sw.cardType }</td><td>${sw.department.dName }</td><td>${sw.swipeTime }</td><td>${sw.phone }</td><td>${sw.recordDate }</td></tr></c:forEach></table>
mapper.xml:
<select id="selectSwipeRecord" resultMap="BaseResultMaps"> select r.id,u.username ,r.card_type,d.d_name,r.swipe_time,r.phone,r.record_date from 201705swipe_record r inner join user u on r.phone=u.phone inner join department d on u.department_id=d.d_id </select> <resultMap type="com.mole.attendance.po.SwipeRecord" id="BaseResultMaps"> <id column="id" property="id" jdbcType="INTEGER" /><result column="cards_number" property="cardsNumber" jdbcType="VARCHAR" /><result column="card_type" property="cardType" jdbcType="VARCHAR" /><result column="swipe_time" property="swipeTime"jdbcType="VARCHAR" /><result column="phone" property="phone" jdbcType="VARCHAR" /><result column="image" property="image" jdbcType="VARCHAR" /><result column="record_date" property="recordDate" jdbcType="TIMESTAMP" /><association property="user" javaType="com.mole.attendance.po.User"><id column="id" property="id" jdbcType="INTEGER"></id><result column="username" property="username" jdbcType="VARCHAR"/></association><association property="department" javaType="com.mole.attendance.po.Department"><id column="d_id" property="dId" jdbcType="INTEGER"></id><result column="d_name" property="dName" jdbcType="VARCHAR" /></association> </resultMap>
dao:
List<SwipeRecord> selectSwipeRecord();
pojo:
public class SwipeRecord {private Integer id;private String cardsNumber;private String cardType;private String swipeTime;private String phone;private String image;private Date recordDate; private User user;private Department department;public User getUser() {return user;}public void setUser(User user) {this.user = user;}public Department getDepartment() {return department;}public void setDepartment(Department department) {this.department = department;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getCardsNumber() {return cardsNumber;}public void setCardsNumber(String cardsNumber) {this.cardsNumber = cardsNumber;}public String getCardType() {return cardType;}public void setCardType(String cardType) {this.cardType = cardType;}public String getSwipeTime() {return swipeTime;}public void setSwipeTime(String swipeTime) {this.swipeTime = swipeTime;}public String getPhone() {return phone;}public void setPhone(String phone) {this.phone = phone;}public String getImage() {return image;}public void setImage(String image) {this.image = image;}public Date getRecordDate() {return recordDate;}public void setRecordDate(Date recordDate) {this.recordDate = recordDate;}@Overridepublic String toString() {return "SwipeRecord [id=" + id + ", cardsNumber=" + cardsNumber+ ", cardType=" + cardType + ", swipeTime=" + swipeTime+ ", phone=" + phone + ", image=" + image + ", recordDate="+ recordDate + ", user=" + user + ", department=" + department+ "]";}public SwipeRecord() {super();}public SwipeRecord(Integer id, String cardsNumber, String cardType,String swipeTime, String phone, String image, Date recordDate,User user, Department department) {super();this.id = id;this.cardsNumber = cardsNumber;this.cardType = cardType;this.swipeTime = swipeTime;this.phone = phone;this.image = image;this.recordDate = recordDate;this.user = user;this.department = department;}
serviceImpl:
@Overridepublic List<SwipeRecord> selectSwipeRecord() {return swipeRecordDao.selectSwipeRecord();}
controller:
@RequestMapping("/selectSwipeRecord")public String selectSwipeRecord(HttpServletRequest request,ModelMap modelMap){List<SwipeRecord> swipeRecords = swipeRecordService.selectSwipeRecord();modelMap.addAttribute("swipeRecordList", swipeRecords);return "listAllSwipe";}
阅读全文
0 0
- SSM多表联合查询
- SSM框架 Mybatis联合查询 多表查询 分页
- 利用SSM(springmvc+spring+mybatis)实现多表联合查询
- 多表联合查询
- 多表联合查询
- 联合多表查询
- 多表联合查询
- 多表联合查询
- SQL 多表联合查询
- Oracle多表联合查询
- php多表联合查询
- SQL 多表联合查询
- ABAP 多表联合查询
- 多表联合查询问题
- thinkPHP多表联合查询
- sql 多表联合查询
- SQL 多表联合查询
- hql多表联合查询
- 连接mysql数据库的配置备忘
- 字符串查找—练习一
- C# 窗体操作汇总
- java.exe和javaw.exe有什么区别?
- AIDL
- SSM多表联合查询
- DatabaseMetaData,ResultSet,ResultSetMetaData三种类型的区别
- caffe win10 ssd训练和预测(CPU)
- mfcs100ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 已经在 MSVCRTD.lib(dllmain.obj) 中定义
- JEESZ RestFul服务介绍
- 逆转字符串
- Eclipse导入已经存在WorkSpace里的工程
- ural 1133. Fibonacci Sequence math
- 线程调用中的一些理解