I'm really stumped on this one. I want to output a list and have the tag file take care of commas, singular versus plural, etc. but when I display the list it completely ignores whitespace so everythingrunstogetherlikethis. I tried using the HTML entities "thinsp", "ensp" and "emsp" (I can't use "nbsp", these have to be breaking), but they're all hideously wide on IE except thinsp which is way too skinny on everything else.
我真的很难过这个。我想输出一个列表,并让标记文件处理逗号,单数与复数等,但是当我显示列表时,它完全忽略了空格,所以allrunstogetherlikethis。我尝试使用HTML实体“thinsp”,“ensp”和“emsp”(我不能使用“nbsp”,这些必须要破坏),但它们在IE上都非常宽,除了thinsp,这太瘦了在其他一切。
Edit: won't work. The output from the tag has no spaces at all. Although any content in the JSP has normal spacing. Obviously I could just put everything in the JSP but this is code that goes on multiple JSPs, so tag files would make a lot of sense.
编辑:将无法正常工作。标签的输出根本没有空格。虽然JSP中的任何内容都具有正常的间距。显然我可以把所有东西都放在JSP中,但这是代码可以在多个JSP上运行,因此标记文件会很有意义。
4 个解决方案
#1
14
It's actually a bug in the EL parser which causes spaces in between EL expressions to be eaten. E.g.
它实际上是EL解析器中的一个错误,它导致EL表达式之间的空格被吃掉。例如。
${bean.foo} ${bean.bar} ${bean.waa}
would get printed as (assuming that they returns the very same String value as its property name is):
将打印为(假设它们返回与其属性名称相同的String值):
foobarwaa
I recall that this issue was reported somewhere before, but I can't seem to find it right now. As far now you can fix it by using JSTL c:out
tag:
我记得以前在某个地方报道了这个问题,但我现在似乎无法找到它。到目前为止,您可以使用JSTL c:out标记来修复它:
<c:out value="${bean.foo} ${bean.bar} ${bean.waa}" />
which correctly get printed as:
正确打印为:
foo bar waa
#2
2
Maybe put the jsp content in an html <pre>
tag? This seems to me to be the right thing to do as the list is pre-formatted content.
也许把jsp内容放在一个html
标签中?在我看来这是正确的事情,因为列表是预先格式化的内容。
#3
0
So you are saying your tag doesn't print out white space at all? Is there any whitespace for it to print out?
所以你说你的标签根本不打印出空格?打印出来有空白吗?
Can you post the code, and a short example of how you use it?
您可以发布代码,以及如何使用它的简短示例吗?
#4
0
I used  
entity instead of space but generally I think this sucks that either ALL whitespace is eaten and one has to hack with entities or you have vast space in the generated HTML code.
我使用的是实体而不是空间,但一般来说,我觉得这很糟糕,要么所有的空白都被吃掉,要么必须破解实体,或者你在生成的HTML代码中有很大的空间。
#1
14
It's actually a bug in the EL parser which causes spaces in between EL expressions to be eaten. E.g.
它实际上是EL解析器中的一个错误,它导致EL表达式之间的空格被吃掉。例如。
${bean.foo} ${bean.bar} ${bean.waa}
would get printed as (assuming that they returns the very same String value as its property name is):
将打印为(假设它们返回与其属性名称相同的String值):
foobarwaa
I recall that this issue was reported somewhere before, but I can't seem to find it right now. As far now you can fix it by using JSTL c:out
tag:
我记得以前在某个地方报道了这个问题,但我现在似乎无法找到它。到目前为止,您可以使用JSTL c:out标记来修复它:
<c:out value="${bean.foo} ${bean.bar} ${bean.waa}" />
which correctly get printed as:
正确打印为:
foo bar waa
#2
2
Maybe put the jsp content in an html <pre>
tag? This seems to me to be the right thing to do as the list is pre-formatted content.
也许把jsp内容放在一个html
标签中?在我看来这是正确的事情,因为列表是预先格式化的内容。
#3
0
So you are saying your tag doesn't print out white space at all? Is there any whitespace for it to print out?
所以你说你的标签根本不打印出空格?打印出来有空白吗?
Can you post the code, and a short example of how you use it?
您可以发布代码,以及如何使用它的简短示例吗?
#4
0
I used  
entity instead of space but generally I think this sucks that either ALL whitespace is eaten and one has to hack with entities or you have vast space in the generated HTML code.
我使用的是实体而不是空间,但一般来说,我觉得这很糟糕,要么所有的空白都被吃掉,要么必须破解实体,或者你在生成的HTML代码中有很大的空间。