第三种利用spring mvc3的注解@ResponseBody
例如:
[java] view plain copy
- @ResponseBody
- @RequestMapping("/list")
- public List<String> list(ModelMap modelMap) {
- String hql = "select c from Clothing c ";
- Page<Clothing> page = new Page<Clothing>();
- page.setPageSize(6);
- page = clothingServiceImpl.queryForPageByHql(page, hql);
- return page.getResult();
- }
然后使用spring mvc的默认配置就可以返回json了,不过需要jackson的jar包哦。
时间: 2024-11-08 12:48:49