Passing dynamic attributes between JSP tags?

I have a set of JSP tags that use dynamic attributes to pass arbitrary HTML attributes to them, for example:

<%-- tag named a:div --%>
<%@ tag dynamic-attributes="attrs" %>
<div <c:forEach var="attr" items="${attrs}"> ${attr.key}="${attr.value}"</c:foreach>>
</div>

Then I have another tag that I want to pass to dynamic attributes, and just pass them to the above tag. Sort of:

<%-- tag using a:div --%>
<%@ tag dynamic-attributes="attrs" %>
<a:div class='big' attrs="${attrs}"/>

But attrs = "$ {attrs}" does not do what I want. Any ideas?

+3
source share
1 answer

I do not think this is possible, unfortunately. The "attrs" object is here java.util.Mapand there is no way to blow it up.

<a:div> Map, . , <a:div> , , - , <c:choose> ?

+3

Source: https://habr.com/ru/post/1713257/


All Articles