用jquery生成二级菜单的实例代码(2)


 public String querySubChannelArticle(){ 
        HttpServletResponse response=getResponse();
        HttpServletRequest request=getRequest();
        response.setContentType("application/json; charset=UTF-8");
        PrintWriter out =null;
        try {
            out = response.getWriter();

            List<Map<String,Object>> list = new LinkedList<Map<String,Object>>();
            if(channelId!=null && !channelId.equals("")){
                Channel tmp = new Channel();
                tmp.setChannelId(Integer.parseInt(channelId));
                subChannelList = subChannelDAO.listSubChannel(tmp);

                for(Object oo:subChannelList){
                    Map<String,Object> obj = new HashMap<String,Object>();
                    SubChannel c = (SubChannel)oo;
                    obj.put("subId", c.getSubId());
                    obj.put("subName", c.getSubName());
                    list.add(obj);
                }
            }
            String outStr = JsonUtil.toJSONStr(list);
            out.println(outStr);
        }catch(Exception e){
        e.printStackTrace();
        }
        out.flush();
        out.close();
        return null;
    }  


其实蛮简洁的

您可能感兴趣的文章:

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

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