标签getBodyContent()输出为NULL,为什么

各路神仙帮忙看看,为什么会出现这样的问题


package com.tags;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;

public class Body
extends BodyTagSupport {

public int doStartTag() throws JspException {
System.out.println("f==" + getBodyContent());
return EVAL_BODY_TAG;
}

public int doEndTag() throws JspException {
return EVAL_PAGE;
}
}

输出f==null

test.jsp
...
<html:example2>
eeeeeeeeeeeeeeeee
</html:example2>

*.tld
<tag>
<name>example2</name>
<tagclass>com.tags.Body</tagclass>
<bodycontent>JSP</bodycontent>
</tag>

老兄,看看标签的生命周期。页面首先访问标签的doStartTag方法,然后根据返回值判断下一步是否访问标签的setBodyContent方法。