json转义字符串
json前台写数据
@RequestMapping("/addUserJson") public void addUserJson(User user,HttpServletRequest request, HttpServletResponse response){ String result = "{\"userName\":\" "+ user.getUserName()+" \", \"age\":\" "+ user.getAge()+" \"}"; PrintWriter out = null; response.setContentType("application/json"); try { out=response.getWriter(); out.write(result); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }