我使用spring MessageSource从我的本地化属性文件中获取消息。
在这种情况下,我会在将邮件发送给用户之前使用它来创建邮件:
String eventTitle = tournament.getEvent().getTitle();
String tournamentMessageTitle = messageSource.getMessage("tournament.subscribe_title", new Object[] {eventTitle}, "", locale);
DateFormat df = new SimpleDateFormat("dd.MM.yyyy");
String formatedDate = df.format(tournament.getDate());
String barName = bar.getName();
String tournamentMessageContent = messageSource.getMessage("tournament.subscribe_content", new Object[] {username, eventTitle, formatedDate, barName}, "", locale);
以下是message.properties
中的属性tournament.subscribe_title = You signed up for "{0}"
tournament.subscribe_content = Hello {0], <br /><br /> You’ve sucessfully signed up for “{1}”. See you on {2} at Meltdown {3}!<br/><br/>You’ll have to confirm your participation with an admin prior to the start of the event.<br/><br/>See you soon!<br/><br/>The Meltdown {3} team
所以在这里,我们有两个用法messageSource.getMessage。第一个工作,第二个抛出IllegalArgumentException:模式中不匹配的大括号。
我尝试更改消息,更改/删除变量,删除引号和双引号,将属性移动到message.properties文件中的其他位置,但我总是得到相同的错误