有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java消息源。getMessage send IllegalArgumentException:模式中的大括号不匹配

我使用SpringMessageSource从本地化属性文件中获取消息

在本例中,我使用它在将邮件发送给用户之前创建邮件:

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);

下面是消息中的属性。性质

tournament.subscribe_title = You signed up for "{0}"
tournament.subscribe_content = Hello {0], <br /><br /> You&rsquo;ve sucessfully signed up for &ldquo;{1}&rdquo;. See you on {2} at Meltdown {3}!<br/><br/>You&rsquo;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用法。获取消息。第一个有效,第二个抛出IllegalArgumentException:模式中不匹配的大括号

我试图更改消息,更改/删除变量,删除引号和双引号,将属性移动到消息中的其他位置。属性文件,但我总是得到相同的错误


共 (0) 个答案