1. Use the Label control page logic case: Simulate the development of the tags-development <c:if> tags-development <c:if><c:else> tags-development of iterative tag development <c:if> tag Case: Tag control class: P
Ackage Com.csdn.web.example;
Import java.io.IOException;
Import javax.servlet.jsp.JspException;
Import javax.servlet.jsp.tagext.JspFragment;
Import Javax.servlet.jsp.tagext.SimpleTagSupport;
public class Demo1 extends Simpletagsupport {private Boolean test;
public void Settest (Boolean test) {this.test = test;
@Override public void Dotag () throws Jspexception, IOException {if (test) {jspfragment JF = This.getjspbody ();
Jf.invoke (NULL); The TLD description document: <?xml version= "1.0" encoding= "UTF-8"?> <taglib xmlns= "HTTP://JAVA.SUN.COM/XML/NS/J2EE" Xmlns:xs I= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "http://java.sun.com/xml/ns/j2ee http:// Java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "version=" 2.0 "> <tlib-version>1.0</tlib-version > <short-name>example</short-name> <uri>example</uri> <tag> <name>if</name> <tag-class>com.csdn.web.example.Demo1</tag-class> &L t;body-content>scriptless</body-content> <attribute> <name>test</name> <required
>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> <tag> <name>choose</name> <tag-class>com.csdn.web.example.ChooseTag</tag-class> < body-content>scriptless</body-content> </tag> <tag> <name>when</name> <
Tag-class>com.csdn.web.example.whentag</tag-class> <body-content>scriptless</body-content> <attribute> <name>test</name> <required>true</required> <rtexprvalue>true< /rtexprvalue> </attribute> </tag> <tag> <name>otherwise</name> <tag-class>co M.csdn.web.example.otherwisetag</tag-class> <body-content>scriptless</body-content> </tag> <tag> <name>forEach</name> <TAG-CLASS&G T;com.csdn.web.example.foreach</tag-class> <body-content>scriptless</body-content> < attribute> <name>var</name> <required>true</required> </attribute> <attribute&
Gt
<name>items</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> </tag> </taglib> JSP files: <%@ page language= "java" import= "java.util.*" pageencoding= " UTF-8 "%> <%@ taglib uri=" Example "prefix=" Example "%> <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >