Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 我可以在表达式中使用消息吗_Spring_Thymeleaf_El - Fatal编程技术网

Spring 我可以在表达式中使用消息吗

Spring 我可以在表达式中使用消息吗,spring,thymeleaf,el,Spring,Thymeleaf,El,我在Spring引导应用程序中使用Thymeleaf 3。 目前,我想在EL表达式(Spring EL)中使用消息表达式 第一个用例:修剪消息 data:title="${#{message.key}.trim()} 第二个用例:有条件地创建一个属性,并将消息作为其值 data:title="${condition ? #{message.key} : ''} 这两个示例都会产生语法错误,因为#{不是允许的表达式开头 有什么想法可以实现我想要的吗? 查看以下教程:@karen我做了。不幸的是

我在Spring引导应用程序中使用Thymeleaf 3。 目前,我想在EL表达式(Spring EL)中使用消息表达式

第一个用例:修剪消息

data:title="${#{message.key}.trim()}
第二个用例:有条件地创建一个属性,并将消息作为其值

data:title="${condition ? #{message.key} : ''}
这两个示例都会产生语法错误,因为
#{
不是允许的表达式开头

有什么想法可以实现我想要的吗?


查看以下教程:@karen我做了。不幸的是,“4.1消息”一章没有提到这一点。:(显然我必须阅读整个教程……啊,我错过了。我已经快要创建自己的Spring bean了,它将完全完成
#Messages
正在做的事情。非常感谢!
data:title="${#messages.msg('key').trim()}"

data:title="${condition ? #messages.msg('key') : ''}"