Experience 13--jsp simple tag case analysis. Doc__js

Source: Internet
Author: User
Tags tld
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> &LT;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" >  

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.