Reference: http://liuna718-163-com.iteye.com/blog/1318991
1. The iterationtag interface is a sub-interface of the tag interface, which has a doafterbody method. This method determines whether to repeatedly execute the TAG body content.
2. The Web Container executes the custom tag process as follows:
Call the setpagecontent () method during initialization. After the setparent method is called
2.1the Web Container first executes the start tag of the custom tag and calls the dostarttag method.
2.2 If the dostarttag method returns eval_body_include, the Web Container will call the doafterbody method of the label class after the content of the label body is executed;
If the dostarttag method returns skip_body, The doafterbody method will not be called, and the Web Container will directly call the doendtag method in the tag class.
2.3 If the doafterbody method is called and the method returns eval_body_agin, the Web Container will execute the content of the label body again;
If the doafterbody method returns the skip_body, the Web Container will call the doendtag method of the label class.
2.4 If the doendtag method returns eval_page, the Web Container executes the content following the tag;
If the doendtag method returns skip_page, the Web Container ignores the content after the custom tag.
3. Implement the bodytagsupport class of the bodytag Interface
Pay attention to the following points when writing code:
Because the setpagecontext method, setparent method, setter method of attributes, and dostarttag method are called before the setbodycontent method, you cannot use bodycontext objects in these methods, that is to say, the bodycontent object can be used only in the methods called after the setbodycontent method, such as the doinitbody, doafterbody, and doendbody methods.
If you want to modify the content of the TAG body, you can only process the content after the TAG body is executed. That is to say, you can only write the processing code in the doafterbody or doendtag method.