利用SpringMvc和MyBatis实现员工列表显示页面
首先使用MapperScannerConfigurer将带有@MyBatisRespository注解的Dao接口扫描生成MapperFacotryBean实例
然后通过MapperFactoryBean生成Dao实例给SpringMvc的Controller对象注入。
最后Controller将DAO查询返回的记录传递到Jsp显示
步骤
1:建工程,导包
2:新建Emp实体类和EmpMapper.xml映射文件
package com.eduask.mvc.entity;
import java.util.Date;
public class Emp { private Integer empno; private String ename; private String job; private Integer mgr; private Date hiredate; private Double sal; private Double comm; private Integer deptno; public Integer getEmpno() { return empno; } public void setEmpno(Integer empno) { this.empno = empno; } public String getEname() { return ename; } public void setEname(String ename) { this.ename = ename; } public String getJob() { return job; } public void setJob(String job) { this.job = job; } public Integer getMgr() { return mgr; } public void setMgr(Integer mgr) { this.mgr = mgr; } public Date getHiredate() { |