- @RequestMapping(value="/book/getBook.do", produces = "text/html;charset=UTF-8")
- public @ResponseBody String getBook(String name){
- List<Book> list =bookService.getBook();
- for(Book bo:list){
- System.out.println("id:"+bo.getId()+" name:"+bo.getName()+" author:"+bo.getAuthor());
- }
- String json = JSONObject.toJSONString(list);
- System.out.println("json:"+json);
- return json;
- }
- 在 注解处 加入
produces
=
"text/html;charset=UTF-8"
即可
时间: 2024-10-05 23:10:36