Servlet------>jsp Custom Label 4 (repeat tag body)

Source: Internet
Author: User

4. Control label body content execution five times
Here This method is inherited the tag interface implementation class, this implementation class not only implements the tag interface, also has the tag interface sub-interface, namely Iterationtag
The Doafterbody () method and the Eval_body_again constant are added to the sub-interface, in order to achieve the label body repetition
Tagrepeat.java

Package Tag;import Javax.servlet.jsp.jspexception;import Javax.servlet.jsp.tagext.iterationtag;import Javax.servlet.jsp.tagext.tag;import javax.servlet.jsp.tagext.tagsupport;/** * @author: Snowing * @date  : April 18, 2017 * control tag body content execution five times */public class Tagrepeat extends TagSupport {int x=5; @Overridepublic int doStartTag () throws Jspe Xception {return tag.eval_body_include;//here to get tag body contents} @Overridepublic int Doafterbody () throws Jspexception {// This method is the end of the label body, before the end of the tag execution x--;if (x>0) {return iterationtag.eval_body_again;//and then output once the label body content}else{return Iterationtag.skip_body;} End label Repeat}}

Servlet------>jsp Custom Label 4 (repeat tag body)

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.