2015-03-02 479 views
8

我正在使用Thymeleaf #dates.format()函數查看圖層中的格式日期。我爲圖片的日期格式創建了一個國際化屬性文件。我正在使用#dates.format(date, (#{app.dateformat}))這樣的功能。但是Thymeleaf拋出一個解析異常。因爲thymeleaf現在解決了app.dateformat。我如何在百里香中使用日期格式國際化的方式。下面是一個例外:Thymeleaf:使用#dates.format()函數格式化日期和國際化。

org.springframework.expression.spel.SpelParseException: EL1043E:(pos 37): Unexpected token. Expected 'identifier' but was 'lcurly({)' 

回答

15

你應該使用這個語法來代替:

${#dates.format(date, #messages.msg('app.dateformat'))} 

#messages:獲取內部變量表達式外部化消息的工具方法,以同樣的方式,因爲他們將使用獲得#{...} 句法。

Source

+0

感謝@heRoy,這是爲我工作。 – 2015-03-02 13:44:56

+0

我可以在2.1版本中使用這個sintax嗎? – 2016-11-09 15:03:24