zoukankan      html  css  js  c++  java
  • [转][Java]简单标签库简介

    public class SimpleTagDemo extends SimpleTagSupport {
        @Override
        public void doTag() throws JspException, IOException {
            JspFragment jf = this.getJspBody();
            // 下面两句效果相同,都是把标签体重复 5 次
            for(int i=0;i<5;i++){
                jf.invoke(this.getJspContext().getOut());
                //jf.invoke(null);
            }
        }
    }

    以上代码也能达到重复 5 次标签体内容的效果。

    public class SimpleTagDemo extends SimpleTagSupport {
        @Override
        public void doTag() throws JspException, IOException {
            JspFragment jf = this.getJspBody();
            StringWriter sw = new StringWriter();
            jf.invoke(sw);
    
            String content = sw.toString();
            content = content.toUpperCase();
            this.getJspContext().getOut().write(content);
        }
    }

    以上代码也能达到修改标签体效果

  • 相关阅读:
    Minimum Path Sum
    Unique Paths II
    Unique Paths
    Rotate List
    Permutation Sequence
    Merge Intervals
    Jump Game
    Group Anagrams
    Combination Sum II
    评分
  • 原文地址:https://www.cnblogs.com/z5337/p/6954316.html
Copyright © 2011-2022 走看看