问题
I'm looking to set the key value pairing of a HashMap using JSTL only. Is this possible?
I know how to retrieve the key value pairs, but I haven't found a way to set them.
Any help would be appreciated.
Example of retrieving HashMap key/value pairs using JSTL:
<c:forEach var="hash" items="${myHashMap}">
<c:out value="${hash.key}" />
<c:out value="${hash.value}" />
...
回答1:
You can use the <c:set>.
<c:set target="${myHashMap}" property="key" value="value"/>
回答2:
I wouldn't use JSTL to do that, but straight-up JSP will get it done...
<%
myHashMap.put("hello", "world");
%>
来源:https://stackoverflow.com/questions/8750213/using-jstl-how-to-put-a-value-into-a-hashmap