@ResponseBody @RequestMapping(value = "/queryStudent.json", method = GET) @ApiOperation(value = "查询学生") public JsonDatastudentQueryByNameOrPhone(@RequestParam(required = false) String keyword, @RequestParam(required = false, defaultValue = "10") int limit, @RequestParam(required = false, defaultValue = "1") int offset) { List students = stuCourseService.queryStudent(keyword,limit,offset); int total = stuCourseService.countStudent(keyword); JsonData data = new JsonData<>(); data.setTotal(total); data.setRows(students); return data; }
springmvc中的controller
jsp:
1、引入
<script
src="<c:url value="/static/js/plugins/bootstrap-table/bootstrap-table.min.js"/>"></script> <script src="<c:url value="/static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"/>"></script>2、页面
<div class="row">
<table id="querylist" class="table table-striped"></table> </div>3、js
var $table = $('#querylist'); $(function() { $table .bootstrapTable({ columns : [ { field : 'name', title : '姓名', align : 'center' },…… { field : 'lastSignupTime', title : '最后一次报读学期', align : 'center', formatter : function(value, row, index) { if(row.lastSignupTime){ var date = new Date(row.lastSignupTime); Y = date.getFullYear() + '-'; M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; D = date.getDate() + ' '; return Y+M+D;} } }, { field : '', title : '报班', align : 'center', formatter : function(value, row, index) { var s = ''; return s; } }], queryParams : queryParams, method : 'get', sortName : '', sortOrder : 'desc', pagination : true, sidePagination : 'server', pageNumber : 1, pageSize : 10, pageList : [ 5, 10, 20 ], url : hostUrl + '/stuCourse/queryStudent.json' }); }); function queryParams(params) { return { keyword : $("#keyword").val(), limit : params.limit, offset : params.offset }; } function queryStudent(){ $table.bootstrapTable('refresh', { url : hostUrl + '/stuCourse/queryStudent.json' }); } function baoban(sno){ window.location.href = hostUrl + '/stuCourse/courseQuery/' + sno; }
4、页面效果