我在Spring Boot应用程序中使用Thymeleaf 3。目前,我需要在EL表达式(Spring EL)中使用消息表达式。
第一个用例:裁剪消息
data:title="${#{message.key}.trim()}第二个用例:有条件地创建一个以消息作为其值的属性
data:title="${condition ? #{message.key} : ''}这两个示例都会产生语法错误,因为#{不是表达式允许的开始。
有什么办法可以实现我想要的东西吗?
发布于 2018-01-13 01:25:10
In both cases you'll want to use the #messages utility object.
data:title="${#messages.msg('key').trim()}"
data:title="${condition ? #messages.msg('key') : ''}"https://stackoverflow.com/questions/48231060
复制相似问题