Thymeleaf:使用#dates.format()函数进行国际化格式化日期.

Har*_*ara 9 java spring-mvc thymeleaf

Thymeleaf #dates.format()在视图层使用格式日期功能.我为pic创建了一个internatinalization属性文件的日期格式.我正在使用这样的#dates.format(date, (#{app.dateformat}))功能.但Thymeleaf抛出一个解析异常.因为百里香现在解决了app.dateformat.我如何在百里香中使用日期格式国际化方式.以下是一个例外:

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

lgd*_*lgd 16

您应该使用此语法:

${#dates.format(date, #messages.msg('app.dateformat'))}
Run Code Online (Sandbox Code Playgroud)

#messages :用于在变量表达式中获取外部化消息的实用程序方法,与使用#{...}语法获取它们的方式相同.

资源