gpt4 book ai didi

java - 带有多个参数的 Spring 消息标签

转载 作者:IT老高 更新时间:2023-10-28 13:44:14 25 4
gpt4 key购买 nike

我正在尝试获取如下 i18n 消息:

messageCode=测试 {0} 和 {1} 和 {2} 的消息。

在jsp中,我有这个:

<spring:message code="messageCode" 
arguments="${value1},${value2},${value3}"
htmlEscape="false"/>

论据:

value1=A,B
value2=C,D
value3=E,F

我想要的输出:

Test message for A,B and C,D and E,F 

实际输出:

Test message for A and B and C

有什么办法可以克服吗?谢谢。

乔治

最佳答案

问题的原因是,(逗号)是默认的分隔符。所以最后spring消息标签会得到参数arguments的字符串A,B,C,D,E,F,并将这个字符串分成6个不同的消息的内部参数。

您必须更改分隔符。例如,如果您使用 ;,那么它将起作用。

<spring:message code="messageCode"
arguments="${value1};${value2};${value3}"
htmlEscape="false"
argumentSeparator=";"/>

@见 Spring Reference: Appendix F.6 The Message Tag

关于java - 带有多个参数的 Spring 消息标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8588365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com