如何在Spring 3 / Thymeleaf中显示带参数的本地化消息 [英] How to show localization messages with parameters in Spring 3 / Thymeleaf
本文介绍了如何在Spring 3 / Thymeleaf中显示带参数的本地化消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Spring 3和Thymeleaf制作一些网页,我迷失了如何显示这样的消息:
I'm using Spring 3 and Thymeleaf to make some webpages and I am lost as for how to show messages like this:
welcome.message = Hello {0 },欢迎!
welcome.message=Hello {0}, welcome!
然后用百万美元标签内的用户名替换{0}:
and then replace {0} with the user name inside thymeleaf tags:
<h1 th:text="#{welcome.message}">Welcome Placeholder</h1>
我甚至不确定{0}是否是捆绑消息的正确语法。
I'm not even sure if {0} is the right syntax for the bundle message.
推荐答案
你可以使用
#{welcome.message(${some.attribute})}
其中 some.attribute
将是替换 {0}
时使用的值。
where some.attribute
would be the value to use when replacing {0}
.
您应该能够用逗号分隔()
之间的值,以添加更多要使用的值。
You should be able to comma separate the values between the ()
to add more values to be used.
这篇关于如何在Spring 3 / Thymeleaf中显示带参数的本地化消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文