【问题标题】:Spring message in form tag doesn't appear correctly表单标签中的 Spring 消息未正确显示
【发布时间】:2015-01-06 10:59:52
【问题描述】:

我正在尝试将 spring:message 标记插入form:...tag,这是代码:

<spring:message code="section.Wiki.titleofthearticle" var="intitule"/>
<form:input type="text" placeholder="Introduction " title="${intitule}"
 path="wikiArticleTitle" required="true"/>

我的消息属性值是这样的:section.Wiki.titleofthearticle=**Intitule de l'article**

但不幸的是,我的标题属性显示如下:Intitule de l&amp;#39;article

有没有办法正确显示?

【问题讨论】:

  • 您可以尝试特殊字符的url编码。
  • 当我把我的 var ${intitule} 放在一个属性而不是“title”属性中时,它就像一个魅力,所以我不认为这是编码问题

标签: spring jsp character-encoding internationalization


【解决方案1】:

改变:

&lt;spring:message code="section.Wiki.titleofthearticle" var="intitule"/&gt;

收件人:

&lt;spring:message htmlEscape="false" code="section.Wiki.titleofthearticle" var="intitule"/&gt;

Spring:message docs

【讨论】:

  • hanya khoya beginmoh :)
【解决方案2】:

使用一次消息编码(URLEncoder 中有预定义的方法)

URLEncoder.encode(String s, String esc);

第一个参数是要翻译的字符串,第二个参数是你想要的字符编码。

【讨论】:

  • 如何解决这个问题?假设所有工作都必须在 JSP 文件中完成?
  • 您可以在 scriptlet 中编写此 java 代码并检查(导入 ULDEncoder)。你也可以在 JS 中做同样的事情(有编码的内置函数)
猜你喜欢
  • 2012-08-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多