一天没有解决的小问题,请教各位
jsp代码
<script language= "javascript ">
var nodes = new Array();
nodes[0] = new Node(1, 'zzzzz ', ' ', ' ',0, 'true ');
<%
List nodelist = (List)request.getAttribute( "nodes ");
//session.removeAttribute( "tree_folder ");
int index = 1;
Iterator roomIt = nodelist.iterator();
while(roomIt.hasNext()){
Node room = (Node)roomIt.next();
int parent = index;
out.println( "nodes[ "+index+ "] = new Node( "+(index + 1) + ", ' "+room.getName()+ " ', ' "+room.getPath()+ " ', ' ',0, 'true '); ");
index++;
java.util.Iterator casesIt = room.getChildren().iterator();
while(casesIt.hasNext()){
Node cases = (Node)casesIt.next();
out.println( "nodes[ "+index+ "] = new Node( "+(index + 1)+ ", ' "+cases.getName()+ " ', ' "+cases.getPath()+ " ', ' ', "+parent+ ", 'false '); ");
index++;
}
}
%>
错误提示:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /mainframe/menulist.jsp:25
22: List nodelist = (List)request.getAttribute( "nodes ");
23: //session.removeAttribute( "tree_folder ");
24: int index = 1;
25: Iterator roomIt = nodelist.iterator();
26: while(roomIt.hasNext()){
27: Node room = (Node)roomIt.next();
28: int parent = index;
java.lang.NullPointerException
org.apache.jsp.mainframe.menulist_jsp._jspService(menulist_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.20 logs.
Apache Tomcat/5.5.20
[解决办法]
客户端脚本与服务端脚本不是同一个作用域
[解决办法]
nodelist是空呀,没有把东西传过来,request.getAttribute( "nodes ")返回的是null。
[解决办法]
“空值是没有任何属性的”
试问下如果一个空值能否点出属性呢?
这样的问题怎么这么多!
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html