2

我正在“国际化”我的应用程序,它基于 SEAM 2 / JSF 1.2

让我烦恼的一件事是在消息包中有 HTML 标记,如果可能的话,我想避免这种情况,例如我有以下 HTML

<p>Click <span class="link" id="trigCl">here</span> to register your account.</p>

我想将其分解为以下内容:

<h:outputFormat escape="false" value="#{messages['registerAccountText']}">
    <f:param value="<span class='link' id='trigCl'>#{messages['here']}</span>" />
</h:outputFormat>

使用以下捆绑条目:

registerAccountText=Click {0} to register your account.

但正如你猜到的那样,我得到以下...

The value of attribute "value" associated with an element type "f:param" must not contain the '<' character.

是否有 a) 解决此问题的方法,或 b) 解决此问题的更好方法(不涉及完全重写标记)?

4

1 回答 1

2

刚刚从无处不在的 BalusC 中发现了一个类似问题的答案,它演示了一种在 f:param 中转义 HTML 的方法

<h:outputFormat escape="false" value="#{messages['registerAccountText']}">
    <f:param value="&lt;span class='link' id='trigCl'&gt;#{messages['here']}&lt;/span&gt;" />
</h:outputFormat>

不完全是最干净的解决方案,但在我可以升级到 JSF 2.0 之前,它必须这样做

于 2013-04-13T20:29:50.840 回答