当前页面: 开发资料首页 → JSP 专题 → (100分求助)运行jsp页面空白问题
(100分求助)运行jsp页面空白问题
摘要: (100分求助)运行jsp页面空白问题
目的是要在页面中显示分类树,节点来源是从外部取来的LIST集合,集合中提供了取得节点ID,parentid等节点信息的方法。
最后分类树有JS生成(这部分已经写好并测试成功)
现在只需要生成一个xml格式的字符串作为参数即可,比如load("<?xml encode=/"utf-8/"?>....")
节点之间是嵌套的,如下
我的思路是用递归的方法遍历集合,并将节点信息存入StringBuffer中,代码见下面,我在本地做了测试,模拟了集合的数据,结果是正确的,但是一放到应用中JSP页就变为空白,连原来的静态内容没了,google了一下,说可能还是<%%>中间的代码逻辑问题
请各位达人指点一下小弟,实在是让人头大,多谢
代码如下:
<%!
//递归方法
public StringBuffer insert(int _id , java.util.List _list , StringBuffer _XmlString)
{
for(int j=0;j<_list.size();j++)
{
int id1 = ((com.thtf.common.model.MenuDTO)_list.get(j)).getJdid();
int parentid1 = Integer.parseInt(((com.thtf.common.model.MenuDTO)_list.get(j)).getParentJdid());
String href1 = "http://10.11.252.52:9080" + ((com.thtf.common.model.MenuDTO)_list.get(j)).getUrl();
String name1 = ((com.thtf.common.model.MenuDTO)_list.get(j)).getJdmc();
if(_id == id1){continue;}
if(parentid1 == _id)
{
_XmlString.append("
");
insert(id1,_list,_XmlString);
}
}
return _XmlString;
}
%>
...
<td width="168" align="center" background="images/2_left3.gif"><table width="87%" border="0" cellspacing="0" cellpadding="0">
<%
String NodeId = request.getParameter("id");
//out.print(NodeId);
com.thtf.common.util.ZKAdapter instance =com.thtf.common.util.ZKAdapter.getInstance();
java.util.List list= instance.getMenuRights("trs",NodeId,true);
StringBuffer XmlString = new StringBuffer("<?xml version=/"1.0/" encoding=/"gb2312/"?>
");
for(int i=0; i {
int id = ((com.thtf.common.model.MenuDTO)list.get(i)).getJdid();
int parentid = Integer.parseInt(((com.thtf.common.model.MenuDTO)list.get(i)).getParentJdid());
String href = "http://10.11.252.52:9080" + ((com.thtf.common.model.MenuDTO)list.get(i)).getUrl();
String name = ((com.thtf.common.model.MenuDTO)list.get(i)).getJdmc();
if(parentid==Integer.parseInt(NodeId))
{
XmlString.append("");
insert(id,list,XmlString);
}
}
XmlString.append("");
String MyString = XmlString.toString();
%>
<script src="menu.js"></script>
<script language="javascript">