spring - 为什么在某些语言环境中未正确填写 Spring MessageSource 参数?

标签 spring internationalization arguments double-quotes

mailconfirm.mail.body=<html><body><h3 style="margin: 0 0 1em;">Hi, {0}!</h3>\
    To confirm your email address click on the confirmation link given bellow. If clicking on the link doesn't work, copy and paste the link in a new browser tab. <br /><br />\
    <a href="http://www.domain.com/confirm_email.html?action=activate&hash={1}">http://www.domain.com/confirm_email.html?action=activate&hash={1}</a><br /><br />\
    Kind regards,<br />\
    Your Something
    </body></html>

以上是用于下面代码的特定消息。

String country = "AU";
Object[] args = new Object[] { account.getLogin(), confirm.getHash() };

helper.setText(appContext.getMessage("mailconfirm.mail.body", args,
                new Locale(country)), true);

我调试了两个参数,它们都有正确的值。在调试 appContext.getMessage 行时,我看到 {1} 参数未填充正确的值,但 {0} 是。

有什么想法可能是错的吗?我怀疑这可能是一些语言环境问题。

最佳答案

问题解决了! 问题似乎是因为邮件 mailconfirm.mail.body 在 {0} 之后和 {1} 之间的某处包含一个撇号。将 doesn't 替换为 does not 后,它解决了问题。我不知道那里不能使用撇号。 附言这是一个错误还是只是我的错误,应该转义撇号?

mailconfirm.mail.body=<html><body><h3 style="margin: 0 0 1em;">Hi, {0}!</h3>\
    To confirm your email address, click on the confirmation link given bellow. If clicking on the link doesn't work, copy and paste the link in a new browser tab. <br /><br />\
    <a href="http://www.domain.com/confirm_email.html?action=activate&hash={1}">http://www.domain.com/confirm_email.html?action=activate&hash={1}</a><br /><br />\
    Kind regards,<br />\
    Your Something
    </body></html>

一个花了我大约一个小时来弄清楚并插入修复。哈哈哈..从现在开始我认为撇号是邪恶的!

关于spring - 为什么在某些语言环境中未正确填写 Spring MessageSource 参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6332378/

相关文章:

java - redisTemplate @Resource 不适用于 Spring Framework

php - 如何在 Symfony 的 Twig 模板中查找非国际化字符串

internationalization - gettext (gettext-commons) 或坚持使用 java i18n

java - 包含阿拉伯和西方字符的字符串连接

java - Spring Annotation Configs - 基于 YAML 配置动态创建类

java - Spring Batch从2.1.1升级到4.1.1版本后出现异常 "java.lang.IllegalStateException: Existing transaction detected in JobRepository."

java - 如何在 finally block 的事务上下文中处理异常?

arrays - 在golang中将数组作为参数传递

database - 奥帕 : passing database as function parameters

Python将列表作为参数传递