Jsp 为什么getBodyContent().getString()在使用BodyTagSupport的JSTL自定义标记开发中返回空值?

Jsp 为什么getBodyContent().getString()在使用BodyTagSupport的JSTL自定义标记开发中返回空值?,jsp,jstl,Jsp,Jstl,当我尝试使用检索自定义标记的主体时,我正在使用BodyTagSupport BodyTagSupport类的getBodyContent()方法虽然我的标记有body,但我得到了getBodyContent()的空值。getString()evn。有没有办法获得自定义标记的bodycontent(使用BodyTagSupport而不是SimpleTagSupport) 我有如下自定义标签 <custom:label>this is body of tag</custom:lab

当我尝试使用检索自定义标记的主体时,我正在使用BodyTagSupport BodyTagSupport类的getBodyContent()方法虽然我的标记有body,但我得到了getBodyContent()的空值。getString()evn。有没有办法获得自定义标记的bodycontent(使用BodyTagSupport而不是SimpleTagSupport)

我有如下自定义标签

<custom:label>this is body of tag</custom:label>
在tld文件中,我声明了

<body-content>JSP</body-content>
JSP

但是我在变量body中得到了空值。

您不使用
getBodyContent()
,因为它只在标记初始化后才起作用。改用
bodyContent
对象,并且必须放在
doEndTag

pageContext.getOut().print(bodyContent.getString())

<body-content>JSP</body-content>