我正在使用 Thymeleaf#dates.format()
函数在 View 层中格式化日期。我为 pic 日期格式创建了一个国际化属性文件。我正在使用 #dates.format(date, (#{app.dateformat}))
这样的函数。但是 Thymeleaf
抛出一个解析异常。因为 thymeleaf 现在解析 app.dateformat
。我如何在 thymeleaf 中使用日期格式国际化方式。以下是一个异常(exception):
org.springframework.expression.spel.SpelParseException: EL1043E:(pos 37): Unexpected token. Expected 'identifier' but was 'lcurly({)'
最佳答案
你应该改用这个语法:
${#dates.format(date, #messages.msg('app.dateformat'))}
#messages
: utility methods for obtaining externalized messages inside variables expressions, in the same way as they would be obtained using #{...} syntax.
关于java - Thymeleaf:使用#dates.format() 函数来格式化具有国际化的日期。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28808838/