需求:
點擊樹的某個節點,在節點下增加用戶或者部門,要求點擊樹節點後,樹的名字被列表自動獲取,不需要手動去輸入。
代碼:
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());
}