ztree树与列表名字获取

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zq123lcx/article/details/83896914

需求:

点击树的某个节点,在节点下增加用户或者部门,要求点击树节点后,树的名字被列表自动获取,不需要手动去输入。

代码:

public String FormPage(Model model, HttpServletRequest request)
    {
        String parentId = request.getParameter("parentId");
        CatalogclassifyBean beans =         
        ClassifyService.getById(parentId);
        ManageBean bean = new ManageBean();
        if(beans !=null){
            bean.setName(beans.getName());
        }
        bean.setParentId(parentId);
        setDicData(model);
        model.addAttribute("action", "add");
        model.addAttribute("obj", bean);
        return "system/catalog/ManageAdd";
    }

主要代码:

//获取到树的节点ID
String parentId = request.getParameter("parentId");
//通过树的节点ID获取到下面的bean
        classifyBean beans = ClassifyService.getById(parentId);
        CatalogManageBean bean = new CatalogManageBean();
//判断beans如果不为空
        if(beans !=null){
//获取到树的名字,然后设置列表相关行的名字
            bean.setZymlfl(beans.getName());
        }

猜你喜欢

转载自blog.csdn.net/zq123lcx/article/details/83896914
今日推荐