基于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(); } }