在 JSF 中显示辅助 bean 的值时不要折叠空格
我发现JSF页面上显示的backing bean值会自动折叠空白。如何使显示的值不折叠空白?
例如,我有一个 MBean,它有一个字符串变量 test
并分配值
"test test", when I render it using
<h1>${MBean.test}</h1>
, it just give out test test
which all the white-spaces in the middle collapse to a white-space only.如果我使用
以表格式显示 MBean 中的 ArrayList,也会发生此行为,所有空白也将被折叠。
更新:我仍然认为它特定于 JSF ,因为当我使用
,渲染的输入文本框将折叠所有空白。如何保留此中的所有空白案件??
I found that the backing bean value displayed on the JSF page will collapse the white-space automatically .How can I make the value displayed do not collapse the white-space??
For example , I have a MBean which has a String variable test
and assign the value
"test test"
, when I render it using <h1>${MBean.test}</h1>
, it just give out test test
which all the white-spaces in the middle collapse to a white-space only.
This behavior also happens if I display the ArrayList from the MBean in the table format using the <rich:dataTable>
, all the white-spaces will be collapsed too.
Updated: I still think that it is specific to the JSF , because when I use<h:inputText value="#{MBean.test}"/>
, the rendered input text box will collapse all the white-spaces.How can I preserve all the white-spaces in this case??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是 JSF 所特有的。这是特定于 HTML 的,
您可以通过将其放入 HTML
或者通过应用 CSS
white-space: pre
:(如你看,它也出现在你在 Stackoverflow 上的问题上,因为它也不会通过
white-space: pre
保留空格)This is not specific to JSF. This is specific to HTML
You can fix it by either putting it in a HTML
<pre>
element:Or by applying CSS
white-space: pre
on the HTML element:(as you see, it also occurs on your question here on Stackoverflow as well, since it also doesn't preserve whitespace by
white-space: pre
)Sun 的 JavaServer Faces 实现 (1.2_07-b03-FCS) 在 Webshpere Application Server 7.0.0.21 上也存在与 CSS 空白相同的问题:pre
Sun's JavaServer Faces implementation (1.2_07-b03-FCS) has the same issue on Webshpere Application Server 7.0.0.21 for the CSS white-space: pre