小编典典

Thymeleaf:使用#dates.format()函数格式化具有国际化的日期。

spring-mvc

我正在使用`Thymeleaf

dates.format()函数在视图层中设置日期格式。我为日期格式创建了一个国际化属性文件。我正在使用这样的#dates.format(date,

(#{app.dateformat}))功能。但Thymeleaf抛出一个解析异常。因为百里香现在解决了app.dateformat`。我如何在百里香中使用日期格式国际化方式。以下是一个例外:

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

阅读 4699

收藏
2020-06-01

共1个答案

小编典典

您应该改用以下语法:

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

#messages :实用程序方法,用于获取变量表达式内的外部化消息,与使用#{…}语法获得消息的方法相同。

资源

2020-06-01