如何在JSP中的两个变量之间插入空格?

zw3*_*324 4 html forms jsp el

我在JSP页面上的表单中有一行html,如下所示:

<c:forEach var="entry" items="${set}">
    <input type="checkbox" name="thing" value="${entry.key} ${entry.value}">
</c:forEach>
Run Code Online (Sandbox Code Playgroud)

但是,${entry.key} ${entry.value}提交表单时,键和值之间的空间将丢失.我试着使用\, in that case both the \ are still there when submitting.

It seems that Java EL does not preserve isolated spaces, is that right? If so, is there a valid workaround?

EDIT: This is so silly of me, many thanks to Cthulhu. But I still don't understand the behavior after adding a \.为什么这会导致空间显示?

Ani*_*han 9

您可以使用以下方法插入空格: &nbsp;

角色实体参考

编辑:似乎是EL解析器处理空间的方式中的错误,因此您应该使用html实体&nbsp;或者此处概述的其他方式.