@Controller public class ItemController { @Autowired private ItemService itemService; @RequestMapping("/item/{itemId}") //@ResponseBody public void getItemById(@PathVariable Long itemId,HttpServletResponse response) throws IOException { TbItem tbItem; try { tbItem = itemService.getItemById(itemId);
//如果输出数据中文乱码
//response.setCharacterEncoding("UTF-8");
//response.setContentType("text/html;charset=UTF-8"); response.getWriter().print(tbItem); } catch (Exception e) { e.printStackTrace(); System.out.println("fdjksdjfsdjkfksjdkfjsjdk"); } } }