在请求json的时候 不能用html为后缀的url 否则会报406错误
@RequestMapping(value = "/news", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> news(@RequestParam Integer pageIndex) {
UtilPage utilPage = new UtilPage();
if (pageIndex == null) {
utilPage.setPageIndex(1);
} else {
utilPage.setPageIndex(pageIndex);
}
// 查询总记录数
int totalCount;
Map<String, Object> map = new HashMap<String, Object>();
List<News> newsList = null;
try {
totalCount = newsService.getTotalCount();
logger.debug(totalCount);
utilPage.setTotalCount(totalCount);
// 封装分页参数
map.put("pageIndex",
(utilPage.getPageIndex() - 1) * utilPage.getPageSize());
map.put("pageSize", utilPage.getPageSize());
newsList = newsService.getNewsList(map);
map.put("newsList", newsList);
map.put("utilPage", utilPage);
} catch (Exception e) {
e.printStackTrace();
}
return map;
}