json转换需要的jar包

commons-beanutils-1.7.0.jar
commons-collections-3.2.jar
commons-lang-2.0.jar
commons-logging-1.0.4.jar
ezmorph-1.0.2.jar
json-lib-2.2.2-jdk15.jar

举例:

public void getBannerImages(){
        BannerImageService bannerImageService=new BannerImageService();
        try {
            response.setCharacterEncoding("utf-8");
            response.setContentType("text/html");
            PrintWriter out;
            List<BannerImage> list = bannerImageService.getScrollData();
            JSONArray json = JSONArray.fromObject(list);
            out = response.getWriter();
            out.println(json.toString());
            out.flush();
            out.close();
        } catch (Exception e) {
            logger.info("cgp首页读取banner图片转json数据时出现异常",e);
        }
    }

这样就可以穿到前台了。

 

posted @ 2013-11-27 12:31  为你,奋斗  阅读(900)  评论(0编辑  收藏  举报