Posted in 面试题 onDecember 28, 2012
答:代码如下:
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.*;
public class TimeTag extends SimpleTagSupport{
private boolean isServer = true;
public void setServer(boolean isServer){
this.isServer = isServer;
}
第45 页共59 页
public void doTag() throws JspException, IOException{
JspWriter out = getJspContext().getOut();
if(isServer) {
out.println(new java.util.Date());
}else{
out.println(“”);
}
}
}
import javax.servlet.jsp.tagext.*;
import javax.servlet.jsp.*;
import java.io.*;
public class TimeTag extends SimpleTagSupport{
private boolean isServer = true;
public void setServer(boolean isServer){
this.isServer = isServer;
}
第45 页共59 页
public void doTag() throws JspException, IOException{
JspWriter out = getJspContext().getOut();
if(isServer) {
out.println(new java.util.Date());
}else{
out.println(“”);
}
}
}
如何写一个自定义标签
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@