日期:2014-05-17  浏览次数:20886 次

dtree 通过从数据库的信息添加到节点信息中遇到的问题
前面已经做好,可以通过添加节点信息到数据库,然后在运动dtree的时候,碰到很多问题,先看代码

public List<tree> allTree() throws Exception{
List<tree> list = getTreeService().listTree();
return list;
}
想通过这段代码获得数据库中节点信息的一个集合


<div class="dtree">
<script type="text/javascript">
     tree=new dTree("tree");
     <%response.setCharacterEncoding("UTF-8");
     list_tree lt = new list_tree();
     Iterator<tree> dtolte = lt.allTree().iterator();
     while(dtolte.hasNext()){
     tree tr = dtolte.next();
     %>
     tree.add('<%=tr.getNodeId()%>','<%=tr.getPreId()%>','forward.jsp?name=<%=tr.getName()%>');
     <%
     }
     %>
     document.write(tree);
     </script>
</div>
想通过这段代码来向节点中添加信息(仿照静态节点直接添加信息的过程加了个循环)

然后就出现这样的问题

org.apache.jasper.JasperExceptionjava.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)


root cause 

java.lang.NullPointerException
com.tree.save.action.list_tree.allTree(list_tree.java:88)
org.apache.jsp.tree2_jsp._jspService(tree2_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)



还请看看是哪里出的问题