简单标签库功能

 1 package cn.itcast.web.tag;
 2 
 3 import java.io.IOException;
 4 import java.io.StringWriter;
 5 
 6 import javax.servlet.jsp.JspException;
 7 import javax.servlet.jsp.tagext.JspFragment;
 8 import javax.servlet.jsp.tagext.SimpleTagSupport;
 9 
10 //控制标签体内容为大写
11 public class SimpleTagDemo1 extends SimpleTagSupport {
12     
13     
14     
15     @Override
16     public void doTag() throws JspException, IOException {
17         JspFragment jf = this.getJspBody();
18         StringWriter sw = new StringWriter();
19         jf.invoke(sw);
20         
21         String content = sw.toString();
22         content = content.toUpperCase();
23         
24         this.getJspContext().getOut().write(content);
25     }
26 
27     
28 
29 }
SimpleTagDemo1

 

posted @ 2014-07-29 23:50  是但哥  阅读(151)  评论(0)    收藏  举报