前端:
//从服务器读取数据
loadData: function(pageNum, pageSize){
debugger;
axios.get('${ctx}/queryAdminsByPage',
{
params:{ //请求参数
pageNum : pageNum,
pageSize:pageSize
}
}
).then(
function (params) {
this.tableData = params.data.tableData;
this.totalCount = params.data.totalCount;
}
);
}
后端:因为前端传递的参数是json格式的,所以后台要加上produces = "application/json;charset=utf-8"这句话
,否则后端回报参数找不到错误
@RestController
public class ManagerPersonController {
@Autowired
private ManagerPersonService managerPersonService ;
@RequestMapping(value = "/queryAdminsByPage", method = RequestMethod.GET,produces = "application/json;charset=utf-8")
public Map<String, Object> queryAdminsByPage( @RequestParam(value="pageNum")int pageNum, @RequestParam(value="pageSize")int pageSize) {
Page<AdminInfo> page = managerPersonService.selectAdmins(pageNum, pageSize);Map<String, Object> map = new HashMap<String, Object>();
map.put("tableData", page);map.put("totalCount", page.getTotal());
return map;
}
}