链接:https://pan.baidu.com/s/1WG1HXwdP-IsQvLBdd5QOog
提取码:cy68
在mysql中创建mybatis数据库,并创建customer表,设置id,主键自增,添加sname,jobs,phone字段,如图。
实验任务2:创建项目,引入相关依赖 实验任务3:创建application.properties配置文件 实验任务4:创建customer的pojo类package com.hxci.jcy.pojo;
public class Customer {
private Integer id;
private String sname;
private String jobs;
private String phone;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getJobs() {
return jobs;
}
public void setJobs(String jobs) {
this.jobs = jobs;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
实验任务5:创建customerDao接口
通过@Param注解传值
package com.hxci.jcy.dao;
import com.hxci.jcy.pojo.Customer;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CustomerDao {
//dao--->mapper.xml
public List query(@Param("customer") Customer customer,@Param("pageNo") Integer pageNo);
public void add(Customer customer);
}
实验任务6:创建customerMapper.xml配置文件
实验任务7:创建CustomerService和CustomerServiceImplselect * from customer where 1=1 and sname=#{customer.sname} and jobs=#{customer.jobs} limit 0,#{pageNo}
实验任务8:创建CustomerController
使用postman测试



