JSTL <c: out> where the element name contains a space character
I have an array of values that become available, but unfortunately some variable names include a space. I can’t understand how easy it is to display them on a page. I know that I do not explain this well (I am a JSP developer, not a Java encoder), so hopefully this example will illustrate what I'm trying to do:
<c:out value="${x}"/> displayed on the page (artificially wrapped) as:
{width=96.0, orderedheight=160.0, instructions=TEST ONLY. This is a test., productId=10132, publication type=ns, name=John} I can print the name with
<c:out value="${x.name}"/> no problems. The problem is that when I try to get the "publication type" ... because it has a space, I cannot get <c:out> to display it.
I tried:
<!-- error parsing custom action attribute: --> <c:out value="${x.publication type}"/> <!-- error occurred while evaluating custom action attribute: --> <c:out value="${x.publication+type}"/> <!-- error occurred while parsing custom action attribute: --> <c:out value="${x.'publication type'}"/> <!-- error occurred while parsing custom action attribute: --> <c:out value="${x.publication%20type}"/> I know that the real solution is to format the variable names correctly (i.e. without spaces), but I cannot get the code for quite some time. It can be done? Any help was greatly appreciated.
+4
user79843
source share