前端
table.render({
elem: '#content'
, url: '/HomeworkController/studentSubmitHomework'
, toolbar: '#toolbarDemo'
, cols: [[
{type: 'checkbox', width: 150}
, {field: 'id', title: 'ID', width: 120,}
, {field: 'filename', title: '文件名字', width: 150,}
, {field: 'url', title: '文件路径', width: 150,}
, {field: 'uploaduser', title: '上传用户', width: 150,}
, {field: 'acceptuser', title: '发布用户', width: 220,}
, {field: 'coursename', title: '课程名称', width: 200,}
, {field: 'stopdate', title: '截止时间', width: 200,}
, {field: 'classname', title: '班级名称', width: 300,}
, {field: 'time', title: '发布时间', width: 300,}
, {fixed: 'right', title: '操作', width: 200, toolbar: '#BarContent1'}
]]
,page:true
, layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
, jump: function (obj, first) {
console.log(obj.curr);
console.log(obj.limit);
if (!first) {
var href = '&pageNum=' + obj.curr;
href += '&pageSize=' + obj.limit;
console.log(href)
location.href = href;
}
}
})
controller
@RequestMapping("/studentSubmitHomework")
public Object studentSubmitHomework(@RequestParam("page") int page,
@RequestParam("limit") int limit){
List<Filemanage> list = filemanageService.queryAllInfo();
int count=list.size();
int pages=(page-1)*limit;
int ss=0;
if(count>pages+limit)
{
ss=pages+limit;
}
else {
ss=count;
}
Map<String, Object> result = new HashMap<String, Object>();
List<Filemanage> data=list.subList(pages,ss);
result.put("code", 0);
result.put("msg", "");
result.put("count", count);
result.put("data", data);
return result;
}
最终效果