How to interpolate java expressions in struts attribute strings
Question
I have the following:
<html:select property="myMap(abc)">
What I really need to do, however, is pull the string abc
from a static member of a java class.
I thought something like
<html:select property="myMap(<%=MyClass.FIELD%>)">
, but that didn't work.
What's the correct syntax here?
Solution
Try the following:
<% String name = "myMap(" + MyClass.FIELD + ")"; %>
<html:select property="<%=name%>">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow