JSP:自定义标签之标签

 

public class IfTag extends SimpleTagSupport {

         private boolean test;

 

         public void setTest(boolean test) {

                   this.test = test;

         }

 

         @Override

         public void doTag() throws JspException, IOException {

                   // TODO Auto-generated method stub

                   if(test)//如果有EL表达式就会先执行

                            this.getJspBody().invoke(null);

                   else

                            super.doTag();

                  

         }

}

 

 <% session.setAttribute("user","mmmm") ;%>

 

    未登陆.

   

     

   welcome用户已经登录.

   

   

    ssss

 

   

        Outputs Hello, World

        if

        cn.itcast.web.tag.example.IfTag

        scriptless

       

                 test

                 true

                 true

        

   

你可能感兴趣的:(JavaEE)