How Do I make dynamic-attributes Work in JSP Tag Files?

て烟熏妆下的殇ゞ 提交于 2019-12-05 20:13:36

Isn't "dynamicAttributesVar" the name of the key in the page context that the dynamic attributes are put into? So you could do

<c:out value="${dynamicAttributesVar.someUnexpectedAttributes}"/>

or if you must use scriptlets:

Map dynamicAttributes = (Map) pageContext.getAttribute("dynamicAttributesVar")

(Disclaimer: I haven't tried it, I've just used dynamic attributes in tags with direct Java implementations... but it seems reasonable)

Just trying to get a badge for answering a four year old question.

I have this problem as well and came across some help at O'Reilly to use JSTL instead of scriptlets.

The original poster could have used this code to get all keys/values:

<c:forEach items="${dynamicAttributesVar}" var="a"> 
${a.key}="${a.value}" 
</c:forEach> 

This would get a specific value:

<c:out value="${dynamicAttributesVar['someUnexpectedAttribute']}"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!