注册 登录
编程论坛 J2EE论坛

自定义标签库的问题

roy_guo 发布于 2006-11-19 13:03, 428 次点击
初次接触,请问自定义标签可以输出可以被执行的JS脚本么?
public int doStartTag() throws JspException
{
try
{
context.getOut().print("d = new dTree('d');");
context.getOut().print("d.add(0,-1,'My example tree');");
context.getOut().print("d.add(1,0,'Node 1','example01.html');");
context.getOut().print("d.add(2,0,'Node 2','example01.html');");
context.getOut().print("d.add(3,1,'Node 1.1','example01.html');");
context.getOut().print("d.add(4,0,'Node 3','example01.html');");
context.getOut().print("d.add(5,3,'Node 1.1.1','example01.html');");
context.getOut().print("d.add(6,5,'Node 1.1.1.1','example01.html');");
context.getOut().print("d.add(7,0,'Node 4','example01.html');");
context.getOut().print("d.add(8,1,'Node 1.2','example01.html');");
context.getOut().print("d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');");
context.getOut().print("d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');");
context.getOut().print("d.add(11,9,'Mom\'s birthday','example01.html');");
context.getOut().print("d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');");
context.getOut().print("document.write(d);");
}
catch(IOException ex)
{
throw new JspException(ex.getMessage());
}
return SKIP_BODY;
}
这里需要做什么修改么?
3 回复
#2
神vLinux飘飘2006-11-19 13:05
自定义标签是可以输出被执行的JS脚本的,这点只要了解JAVA的WEB程序的运行周期就明白了

至于你的程序是否需要修改....我怎么知道你要什么样的效果啊...
#3
roy_guo2006-11-19 13:22
context.getOut().print("。。。
里面的东西是要输出的JS原网页里的脚本,我只是想在class文件中动态的生成
#4
roy_guo2006-11-19 16:51

问题解决,是自己的疏忽~~~
谢谢了

1