JSTL <c:out>元素名称包含空格字符

5 java jsp jstl

我有一系列值可用,但遗憾的是一些变量名称包含空格.我无法弄清楚如何在页面中简单地输出这些内容.我知道我不是很好解释(我是JSP设计师,而不是Java编码器)所以希望这个例子能说明我想要做的事情:

<c:out value="${x}"/>
Run Code Online (Sandbox Code Playgroud)

输出到页面(人工包装)为:

{width=96.0, orderedheight=160.0, instructions=TEST ONLY. This is a test.,
 productId=10132, publication type=ns, name=John}
Run Code Online (Sandbox Code Playgroud)

我可以使用输出名称

<c:out value="${x.name}"/>
Run Code Online (Sandbox Code Playgroud)

没问题.问题是当我试图获得"发布类型"...因为它有一个空间,我似乎<c:out>无法显示它.

我试过了:

<!-- 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}"/>
Run Code Online (Sandbox Code Playgroud)

我知道真正的解决方案是使变量名称格式正确(即:没有空格)但我不能让代码更新很长一段时间.可以这样做吗?任何帮助非常感谢.

Edd*_*die 9

你有没有尝试过:

<c:out value="${x['publication type']}"/>
Run Code Online (Sandbox Code Playgroud)

我假设a Map是这背后的Java类型.