读书人

基于json-lib.jar包Json范例程序(转)

发布时间: 2012-10-24 14:15:58 作者: rapoo

基于json-lib.jar包Json实例程序(转)

3)?);???????

?List<String> list = new ArryList<String>(); list.add("a"); list.add("b"); Map<String,List<String>> map = new HashMap<String,List<String>>(); map.put("list",list); MessageUtils.outputJSONResult(JSONObject.fromObject(map).toString(), response); public class MessageUtils { public static void outputJSONResult(String result, HttpServletResponse response) { try { response.setHeader("ContentType", "text/json"); response.setCharacterEncoding("utf-8"); PrintWriter pw = response.getWriter(); pw.write(result); pw.flush(); pw.close(); } catch (IOException e) { e.printStackTrace(); } }

读书人网 >JavaScript

热点推荐