求教如何将后台的json数据传送到前台easyUI

2024-12-31 19:58:46
推荐回答(1个)
回答1:

控制器和jsp:

1234567891011121314151617181920212223242526
@RequestMapping(produces="text/plain;charset=UTF-8",value="datagridToJson") @ResponseBody public String datagridToJson(HttpServletRequest req) throws JsonGenerationException, JsonMappingException, IOException{ ObjectMapper objectMapper = new ObjectMapper(); Map map=new HashMap<>(); Book book=new Book(1, "剪掉你的dingding", "大叔"); Book book1=new Book(2, "洗掉你的dingding", "大姐"); List list=new ArrayList(); list.add(book); list.add(book1); map.put("rows",list); map.put("total",2); return objectMapper.writeValueAsString(map); }

BOOk的ID BOOk作者 BOOk名字