springmvc 返回 json list


        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        List citys = commonInfoService.getDistrictsByProvincesId(provinceId);
        PrintWriter out = null;
        try {
            out = response.getWriter();
            JSONArray jsonArray = new JSONArray();
            jsonArray.addAll(citys);
            out.print("{\"success\":true,\"data\":"+jsonArray+"}");
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
            out.close();
        }
        System.out.println("cityssize:"+citys.size());

posted @ 2014-09-01 14:28  mr.g.  阅读(327)  评论(0编辑  收藏  举报