I have a Struts 2 application using the JSTL/Struts2/DisplayTag tag libraries in my JSP. Is there a way to access the value of a Map in a JSP given the key?
// Action code
Map<String,String> map = new HashMap<String,String>();
mapOnValueStack = map;
//add key/value pairs
fieldKeyOnValueStack = "1";//sets key
....
<%-- JSP code --%>
<s:property value="%{mapOnValueStack.get(fieldKeyOnValueStack)}" />
Essentially I want to do map access within the JSP. Is this possible?
Thanks!
Did you try this :
<s:property value="%{mapOnValueStack.['fieldKeyOnValueStack']}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With