第一步:将工程导入到eclipse里面
第二步:断开和svn的连接
第三步:将工程安装到本地仓库中就变成了一个jar包,然后引用他的路径即可使
第四步:需要对page在SqlMapConfig.xml中配置plugins 还有使用的什么数据库 方言和数据库
第五步:需要在pom文件配置 不记得在哪里配置了
创建一个pojo
public class EasyUIDataGridResult implements Serializable{
private long total;
private List rows;
public long getTotal() {
return total;
}
public void setTotal(long total) {
this.total = total;
}
public List getRows() {
return rows;
}
public void setRows(List rows) {
this.rows = rows;
}
}
接着在service层
//pageHelper的使用
@Override
public EasyUIDataGridResult getItemList(int page, int rows) {
//设置分页的信息
PageHelper.startPage(page, rows);
//执行查询
TbItemExample example = new TbItemExample();
List<TbItem> list = itemMapper.selectByExample(example);
//创建一个返回的对象 将list作为行数放入到result中 将total也放入到result中
EasyUIDataGridResult result = new EasyUIDataGridResult();
result.setRows(list);
//获取分页的结果
PageInfo<TbItem> info = new PageInfo<>(list);
//获取记录总数
long total = info.getTotal();
result.setTotal(total);
return result;
}
接下来在controller层
@RequestMapping("/item/list")
@ResponseBody
public EasyUIDataGridResult getItemList(Integer page,Integer rows){
EasyUIDataGridResult itemList = itemService.getItemList(page, rows);
return itemList;
}