action中调取代码如下:
public String listValueStandard(){ System.out.println("listValueStandard"); List<ValueStandard> types=basicNormService.getAllValueStandard(); List<TreeJson> trees = new ArrayList<TreeJson>(); for(int i=0;i<types.size();i++){ TreeJson json = new TreeJson(); json.setId(types.get(i).getValueStandardId()+""); System.out.println("pid"+types.get(i).getParentId()); if(types.get(i).getParentId()==null){ json.setPid(null); }else{ json.setPid(types.get(i).getParentId()+""); } json.setText(types.get(i).getName()); trees.add(json); } List<TreeJson> jsons = ListToTree.formatTree(trees); JSONArray jsonarray=JSONArray.fromObject(types); listValueStandard=jsonarray.toString(); return "tovaluestandard"; }
这样写无法调取成功,下面是所调用树的
实体类:
public class ValueStandard implements java.io.Serializable { // Fields private Integer valueStandardId; private Integer parentId; private String name; private String note; private String sequence; // Constructors /** default constructor */ public ValueStandard() { } /** minimal constructor */ public ValueStandard(Integer parentId) { this.parentId = parentId; } /** full constructor */ public ValueStandard(Integer parentId, String name, String note, String sequence) { this.parentId = parentId; this.name = name; this.note = note; this.sequence = sequence; } // Property accessors public Integer getValueStandardId() { return this.valueStandardId; } public void setValueStandardId(Integer valueStandardId) { this.valueStandardId = valueStandardId; } public Integer getParentId() { return this.parentId; } public void setParentId(Integer parentId) { this.parentId = parentId; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getNote() { return this.note; } public void setNote(String note) { this.note = note; } public String getSequence() { return this.sequence; } public void setSequence(String sequence) { this.sequence = sequence; } }
解决方案
5
5
是在页面做吗,用z-tree,很好用
2
树可以做菜单,就是难看
5
看看递归算法怎么实现的,模仿一下就可以了。菜单这种简单的递归比较容易实现
2
实体类封装错误
2
感觉用easyUI前台框架写这个比较方便
5
http://blog.csdn.net/yeness/article/details/9496647
2
在后套搭好数据,在前台展示,这个一般是美工设计的,本人做的话到网上找找你喜欢的样式,也很多的
10
哦 误解你意思了,你现在是想在别的页面调用展示树吗?假如是这样可以用ajax调用,把这个方法单独抽取出来直接返回一个json字符串或数据都可以的
2