<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 431,  comments - 344,  trackbacks - 0

    package com.rain.tag;

    import Java.io.IOException;

    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspTagException;
    import javax.servlet.jsp.tagext.BodyTagSupport;

    /*
     * if tag
     * usage:<tag:if value=true>
     *       ...
     *       </tag:if>
     */
    public class IfTag extends BodyTagSupport {

     private boolean value;
     
     public void setValue(boolean value){
      this.value=value;
     }

     @Override
     public int doEndTag() throws JspException {
      // TODO Auto-generated method stub
      try{
       if(bodyContent!=null){
        bodyContent.writeOut(bodyContent.getEnclosingWriter());
       }
      }catch(IOException e){
       throw new JspTagException("IO Error:"+e.getMessage());
      }
      return EVAL_PAGE;
     }

     @Override
     public int doStartTag() throws JspException {
      // TODO Auto-generated method stub
      if(value){
       System.out.println("value is true");
       return EVAL_BODY_INCLUDE;
      }else{
       System.out.println("value is false");
       return SKIP_BODY;
      }
     }
     
     
    }



    package com.rain.tag;

    import Java.io.IOException;

    import javax.servlet.jsp.JspException;
    import javax.servlet.jsp.JspTagException;
    import javax.servlet.jsp.tagext.TagSupport;

    public class OutTag extends TagSupport {

     private Object value;
     
     public void setValue(Object value){
      this.value=value;
     }

     @Override
     public int doEndTag() throws JspException {
      // TODO Auto-generated method stub
      return EVAL_BODY_INCLUDE;
     }

     @Override
     public int doStartTag() throws JspException {
      // TODO Auto-generated method stub
      try{
       System.out.println(value);
       pageContext.getOut().write(value.toString());
      }catch(IOException e){
       throw new JspTagException("IO Error:"+e.getMessage());
      }
      return EVAL_PAGE;
     }
     
     
    }



    <tag>
              <name>if</name>
              <tag-class>com.rain.tag.IfTag</tag-class>
              <body-content>jsp</body-content>
              <attribute>
                <name>value</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
              </attribute>
            </tag>
            <tag>
              <name>out</name>
              <tag-class>com.rain.tag.OutTag</tag-class>
              <body-content>jsp</body-content>
              <attribute>
                <name>value</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
              </attribute>
            </tag>


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "<web-app>
     <taglib>
       <taglib-uri>/demotag</taglib-uri>
       <taglib-location>/WEB-INF/mytag.tld</taglib-location>
     </taglib>
    </web-app>


    <%@ page language="
    Java" contentType="text/html; charset=UTF-8"%>
    <%@ taglib uri="/demotag" prefix="mt" %>
    <html>
    <head>
    <title>Insert title here</title>
    </head>
    <body>
    <%
      boolean flag=true;
      String outValue="Hello World!";
    %>
    <mt:if value="<%=flag%>">
      <mt:out value="<%=outValue%>">
        這是mt:out...>打印的內(nèi)容。
      </mt:out>
    </mt:if>
    <br>
    <mt:if value="false">
      <mt:out value="<%=outValue%>">
        這些內(nèi)容不會(huì)顯示在客戶(hù)端。
      </mt:out>
    </mt:if>
    </body>
    </html>


    結(jié)果顯示:
    控制臺(tái)
    value is true
    Hello World!
    value is false
    頁(yè)面
    Hello World! 這是mt:out...>打印的內(nèi)容。
    posted on 2007-01-22 15:27 周銳 閱讀(317) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): Jsp
    主站蜘蛛池模板: 1区2区3区产品乱码免费| 免费很黄无遮挡的视频毛片| a成人毛片免费观看| 免费一级毛片正在播放| 在线看亚洲十八禁网站| 亚洲成片观看四虎永久| 男女作爱免费网站| 亚洲一区精品伊人久久伊人| a一级爱做片免费| 亚洲日本va中文字幕久久| 两个人看的www高清免费视频| 亚洲综合国产一区二区三区| a在线视频免费观看| 亚洲黄色片免费看| 思思re热免费精品视频66 | 亚洲日本人成中文字幕| 一色屋成人免费精品网站| 亚洲一区二区三区成人网站| 四虎在线视频免费观看| 黄色毛片免费网站| 亚洲人成网7777777国产| 性色午夜视频免费男人的天堂| 亚洲美女视频一区| 免费可以在线看A∨网站| 国产精品久久久久久亚洲小说| 亚洲成AⅤ人影院在线观看| 香蕉免费一区二区三区| 亚洲综合伊人制服丝袜美腿| 国产a不卡片精品免费观看 | 深夜a级毛片免费视频| 亚洲精品无码久久久影院相关影片| 一级毛片全部免费播放| 精品丝袜国产自在线拍亚洲| 亚洲AV中文无码乱人伦| 91精品免费观看| 精品久久久久久亚洲中文字幕| 久久亚洲精品中文字幕三区| 免费在线观看的网站| 一本岛v免费不卡一二三区| 91在线精品亚洲一区二区| 四虎永久在线精品免费观看地址|