网上大多例子是 mySql,今天捣鼓了一个上午,终于写了访问 Oracle的实例,欣喜之余,分享一下下:
1、POM文件
2、UserMapper.xml
select id,login_name,user_name,user_password from sys_user
and login_name like #{loginName}
3、Controller
@RequestMapping("/userList")
@ResponseBody
public Map getAllUserList(@RequestParam(defaultValue = "1") int pageNo, @RequestParam(defaultValue = "10") int pageSize, String loginName) throws Exception {
PageHelper.startPage(pageNo,pageSize);
List
PageInfo
Map map = new HashMap();
map.put("page", pageInfo);
map.put("totalPage", 5);
return map;
}
4、前端页面
var getUserList = function (curr) {
$.ajax({
type: 'POST',
url: '../user/userList',
dataType: 'json',
data: {
pageSize: 10,
pageNo: curr || 1,
loginName: $("#loginName").val()
},
success: function (msg) {
app.result = msg.page.list;
laypage({
cont: 'pagenav', //分页容器
pages: msg.totalPage, //总页数
skin: '#333333',
first: '第一页',
last: '最后一页',
curr: curr || 1,
jump: function (obj, first) {
if (!first) {
getUserList(obj.curr);
}
}
});
}
});
}