Why Spring MessageSource arguments are not filled correctly in some locales?

后端 未结 4 1499
陌清茗
陌清茗 2020-12-29 03:05
mailconfirm.mail.body=

Hi, {0}!

\\ To confirm your email address click on the confirmation
4条回答
  •  爱一瞬间的悲伤
    2020-12-29 03:33

    An alternative is to use String.format, change the {X} for %s.

    mailconfirm.mail.body=

    Hi, %s!

    \ 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.

    \ http://www.domain/confirm_email.html?action=activate&hash=%s

    \ Kind regards,
    \ Your Something String whatEver = messageSource.getMessage("mailconfirm.mail.body", null, locale); whatEver = String.format(whatEver,account.getLogin(), confirm.getHash() );

    Hope it's useful.

提交回复
热议问题