JSP tag file that either outputs its body or returns it in a variable
问题 I have a custom tag in a ".tag" file that computes and outputs a value. Because I cannot post the code here, let's assume a simple example. Content of file mytag.tag: <@tag dynamic-attributes="dynamicParameters"> <%@attribute name="key" required="true"%> <%-- this works fine, in spite of dynamic-attributes --%> <jsp:doBody var="bodyContent/"> <%-- ... here is some code to compute the value of variable "output" --%> ${output} The caller can easily call it like this: <prefix:mytag key="foo"