jsp display of tree structure
100000 root folders
110000 first-level folders
110200 Secondary folder
The easiest way to use controls such as ztree
select * from
(
/*select 'permission tree' name,'0' id,'-1' parentid from dual */
select t.name name,t.id id,t.parentid parentid ,'1' leave from opm_menufolder t
union all select o.name name,o.id id,o.menufolderid,'2' leave from opm_menuitem o
union all select l.name name,l.id id,l.menuitemid ,'3' leave from opm_menuitemlimit l
)
start with parentid is null connect by prior id=parentid ORDER BY leave
It can be displayed by level. This one-time detection is good for regular data structures (digital level recognition), and it can be rendered in the background and in js. It is not easy to mark irregularities.
http://zhoujingxian.iteye.com/blog/935660
JSPs similar to the above websites are not easy to render (if there are no special controls), is there any regular data that can be queried recursively in the background with iteration, and label each time recursion----this is the advantage of iteration and sql ratio
as follows:
select * from (select * from
(
/*select 'permission tree' name,'0' id,'-1' parentid from dual */
select t.name name,t.id id,t.parentid parentid ,'1' leave from opm_menufolder t
union all select o.name name,o.id id,o.menufolderid,'2' leave from opm_menuitem o
union all select l.name name,l.id id,l.menuitemid ,'3' leave from opm_menuitemlimit l
)
start with parentid is null connect by prior id=parentid ORDER SIBLINGS BY parentid) where parentid='100000'
The variables in the iteration are, each time a new one is called back, the previous variables are found one by one, so that they can be combined and accumulated.
========================
Code:
Control
@RequestMapping(value="/system/opmRole/editUi")
public String editUi(OpmRoleVo opmRole,HttpServletRequest request,Model modle) {
Map<String,Object> paramq = new HashMap<String,Object>();
paramq.put("pId", "100000");
String str0="";
String str= treeRead(paramq);//This is requested by ajax on the page
System.out.println(str);
return "/system/opmUser/editUi";
}
@SuppressWarnings("rawtypes")
@RequestMapping(value="/system/opmRole/Auths")
@ResponseBody
public String treeRead(Map<String,Object> param){
String str="";
List<Map> map= opmMenufolderService.getfordMenuLimt(param);
Map<String,Object> param1 = new HashMap<String,Object>();
for(Map p: map){
str+=p.get("ID")+"="+p.get("NAME")+"\n";
param1.put("pId", p.get("ID"));
str + = treeRead (param1);
}
return str;//Directly assemble tree data
}
Service:
@Override
public List<Map> getfordMenuLimt(Map<String,Object> param) {
// TODO Auto-generated method stub
List<Map> map = new ArrayList<>();
map= (List<Map>) opmMenufolderMapper.getfordMenuLimt(param);
return map;
}
OpmMenufolderMapper .java
public interface OpmMenufolderMapper extends Mapper<OpmMenufolder> {
List<?> getfordMenuLimt(Map<String,Object> param);
}
mapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.esteel.system.mapper.OpmMenufolderMapper" >
<resultMap id="BaseResultMap" type="com.esteel.system.bean.OpmMenufolder" >
<!--
WARNING - @mbggenerated
-->
<id column="ID" property="id" jdbcType="VARCHAR" />
<result column="NAME" property="name" jdbcType="VARCHAR" />
<result column="DISPLAYORDER" property="displayorder" jdbcType="DECIMAL" />
<result column="PARENTID" property="parentid" jdbcType="VARCHAR" />
<result column="URI" property="uri" jdbcType="VARCHAR" />
<result column="DESCRIPTION" property="description" jdbcType="VARCHAR" />
<result column="ICONCSS" property="iconcss" jdbcType="VARCHAR" />
<result column="SUBSYSTEM" property="subsystem" jdbcType="VARCHAR" />
</resultMap>
<select id="getfordMenuLimt" resultType="map" parameterType="map">
select * from (select * from
(
select t.name name,t.id id,t.parentid parentid ,'1' leave from opm_menufolder t
union all select o.name name,o.id id,o.menufolderid,'2' leave from opm_menuitem o
union all select l.name name,l.id id,l.menuitemid ,'3' leave from opm_menuitemlimit l
)
start with parentid is null connect by prior id=parentid ORDER SIBLINGS BY parentid) where parentid=#{pId}
</select>
</mapper>