如何在JSF1.2的消息资源包中添加换行符(\ n) [英] How to add new line Character ( \n ) in message resource bundle in JSF1.2

查看:71
本文介绍了如何在JSF1.2的消息资源包中添加换行符(\ n)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的示例JSF应用程序中,我使用页面中的rich:dataTable来显示数据.

In my sample JSF application am using rich:dataTable in page to display data.

我有2个标题,可以在rich:dataTable中显示值,如下所示

I have 2 header to display value in rich:dataTable like following

--------------------------------
| UserDetails | EmpoyeeDetails |
--------------------------------

消息资源束文件中的键和值类似于

In message resource bundle file having key and value like

usrDet =用户详细信息 empDet = EmpoyeeDetails

usrDet = UserDetails empDet = EmpoyeeDetails

我需要在该标题的第一行中显示类似于用户,在下一行中显示详细信息

I need to display like User in one line and Details in next line of that particular header

----------------------
|  User   |  Empoyee |
| Details |  Details |
---------------------

如何在单词之间的消息束中添加换行符?我尝试通过添加十六进制代码,如\#x0A;的\ n的数字代码; ,\ u000A,但不是 为我工作!有想法吗?

How to add new line character in message bundle between words? I tried by adding Hexadecimal code, Numerical Code for \n like , \u000A but its not working for me! Any Idea?

推荐答案

JSF生成HTML. HTML中的换行符不是由\n字符表示,而是由<br>元素表示.

JSF generates HTML. Newlines in HTML are not represented by the \n character, but by the <br> element.

为了使HTML客户端也能够解释\n,您需要放入CSS white-space: prepre-wrap:

In order to have the HTML client to interpret \n too, you need to throw in CSS white-space: pre or pre-wrap:

key = Lorem ipsum.\nDolor sit amet.

<h:outputText value="#{bundle.key}" style="white-space: pre-wrap" />

或者,使用<br>代替,让JSF取消转义.例如

Alternatively, use <br> instead and have JSF unescape it. E.g.

key = Lorem ipsum.<br/>Dolor sit amet.

<h:outputText value="#{bundle.key}" escape="false" />

这篇关于如何在JSF1.2的消息资源包中添加换行符(\ n)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆