java ajax返回 Json 的 几种方式

原文:https://blog.csdn.net/qq_26289533/article/details/78749057

方式 1. : 自写代码转 Json 

需要  HttpHttpServletRequest request  HttpServletResponse response 

后台 :

@RequestMapping(value="/haha") public string xxx { HttpHttpServletRequest request,HttpServletResponse response} { JSONObject json =new JSONObject(); json.put("result"," success") response.setCharacterEncoding("utf-8"); response.setContentType("application/json;charset=utf-8"); PrintWriter out = null; out = response.getWriter(); out.write(json.toString()); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgffzg.html