博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(二 )结构ztree的 ajax交互的简单使用
阅读量:4671 次
发布时间:2019-06-09

本文共 1842 字,大约阅读时间需要 6 分钟。

 在第一篇的基础上更改,在实际项目中的使用。

一:HTML 代码:

             
发送给谁:

    二:action代码:

    /**     * 点击树节点请求此接口     * @param id  :Department的ID     * @param response     * @param model     * @throws Exception     */    @RequestMapping(value="/threeLesson/ztreeAjax",method=RequestMethod.POST)    public void ztreeTestpost(String id,HttpServletRequest request,HttpServletResponse response,ModelMap model) throws Exception{        request.setCharacterEncoding("gb2312");         response.setContentType("text/html;charset=utf-8");            //查找组织下的用户        List
    userList=userService.getUserListByOrganizationId(Long.valueOf(id)); //获取部门 List
    departmentList=departmentService.getDepartmentByParentId(Long.valueOf(id)); StringBuffer strbuf=new StringBuffer("["); if (departmentList.size()>0) { for (int i = 0; i < departmentList.size(); i++) { strbuf.append("{\"id\":"+departmentList.get(i).getId()+",\"pId\":"+departmentList.get(i).getParentId()+",\"name\":\"" +departmentList.get(i).getName()+"\",isParent:true},"); } } if (userList.size()>0) { for (int i = 0; i < userList.size(); i++) { String uid="u"+Long.toString(userList.get(i).getId()); // 加U区分用户ID和组织ID strbuf.append("{\"id\":\""+uid+"\",\"pId\":"+userList.get(i).getOrganizationId()+",\"name\":\"" +userList.get(i).getName()+"\"},"); } } String ss=strbuf.toString(); ss=ss.substring(0, ss.length()-1); ss=ss+"]"; PrintWriter pw = response.getWriter(); pw.write(ss); }

     

    转载于:https://www.cnblogs.com/sunhaoyu/p/4788997.html

    你可能感兴趣的文章
    css div框加小箭头
    查看>>
    Eclipse快捷键与使用技巧总结
    查看>>
    Solr4.8.0源码分析(16)之SolrCloud索引深入(3)
    查看>>
    PEP8 - Python编码规范
    查看>>
    div放置图片总结
    查看>>
    FZOJβ #45. 染色问题
    查看>>
    Python之SYS模块
    查看>>
    webapi文件上传和下载
    查看>>
    HDU 1540 Tunnel Warfare [二分 + 线段树]
    查看>>
    C++:构造函数和析构函数能否为虚函数
    查看>>
    win7便笺元数据损坏,最新解决办法
    查看>>
    mongod
    查看>>
    vim配置python高亮和缩进
    查看>>
    Spring3.0.5 获取表中自增的主键(mysql)
    查看>>
    delphi dxBarManager 的dxBarEdit 输入问题
    查看>>
    Hadoop入门介绍一
    查看>>
    面试经典-分金条
    查看>>
    利用AutoSPSourceBuilder和Autospinstaller自动安装SharePoint Server 2013图解教程——Part 1...
    查看>>
    ZOJ-2972-Hurdles of 110m(记忆化搜索)
    查看>>
    一些新了解到技术
    查看>>