JSTL <c:out> where the element name contains a space character...
Posted
by Shane
on Stack Overflow
See other posts from Stack Overflow
or by Shane
Published on 2009-03-19T03:50:55Z
Indexed on
2010/05/25
3:21 UTC
Read the original article
Hit count: 227
I have an array of values being made available, but unfortunately some of the variable names include a space. I cannot work out how to simply output these in the page. I know I'm not explaining this well (I'm the JSP designer, not the Java coder) so hopefully this example will illustrate what I'm trying to do:
<c:out value="${x}"/>
outputs to 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 output the name by using
<c:out value="${x.name}"/>
no problems. The issue is when I try to get the "publication type"... because it has a space, I can't seem to get <c:out>
to display it.
I have 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 the real solution is to get the variable names formatted correctly (ie: without spaces) but I can't get the code updated for quite a while. Can this be done? Any help greatly appreciated.
© Stack Overflow or respective owner