Cannot invoke comxungecommoncorewebentitybaseTreeEntitygetAncestors because parent is null如何修改为parent为空时ancestors等于0
需要在 TreeEntity 类中修改 getAncestors() 方法,增加判断 parent 是否为空的逻辑,如果为空则返回 0。
示例代码:
public String getAncestors() {
if (parent == null) {
return "0";
}
return parent.getAncestors() + "," + parent.getId();
}
需要注意的是,修改后需要重新编译代码并重新部署应用才能生效。
原文地址: https://www.cveoy.top/t/topic/cng4 著作权归作者所有。请勿转载和采集!