Home > Web Front-end > JS Tutorial > jquery ztree implements drop-down tree box using json data_jquery

jquery ztree implements drop-down tree box using json data_jquery

WBOY
Release: 2016-05-16 16:48:15
Original
1231 people have browsed it

The company's recent project required the use of a tree-shaped drop-down box. I found a lot of source code on the Internet, and finally used zTree to implement it, because the code is more portable and data acquisition is easier. Without further ado, let’s get straight to the code.

index.jsp

Copy code The code is as follows:

<% @ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"% >
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>










  • Select When selecting a city, press the Ctrl or Cmd key to perform multiple selections

  • City:
    Select







spring background

json data class
Copy code The code is as follows:

public class EquipTypeJson {
private String id;
private String pId;
private String name;

public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPId() {
return pId;
}
public void setPId(String pId) {
this.pId = pId;
}
public String getName() {
return name;
}
public void setName(String name) {
this .name = name;
}


}

controller page
Copy code The code is as follows:

public ModelAndView List(HttpServletRequest request, HttpServletResponse response,Product prod) throws Exception {
Map map=new HashMap();
List< EquipTypeJson> list = testService.getAllEquipType();//Get source data from the database
JSONArray jsonArray = JSONArray.fromObject(list); //Convert list data to json object
String json = jsonArray.toString() ; //Convert json object to string
map.put("jsonList", json);
return new ModelAndView("equip/List").addAllObjects(map);
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template