package demo;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;
import java.io.IOException;
import java.io.StringWriter;
/**
* Created by Administrator on 2016/12/8.
*/
public class TagDemo extends SimpleTagSupport{
private String color;
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@Override
public void doTag() throws JspException, IOException {
JspFragment jf = this.getJspBody();
StringWriter sw = new StringWriter();//开启缓存区
jf.invoke(sw);
String str = "<font color='"+this.color+"'>"+sw.toString()+"</font>";
this.getJspContext().getOut().print(str);
}
}
JSP Tag
点赞
收藏