首页 > 解决方案 > 使用 thymeleaf 从字符串中删除单引号字符

问题描述

我是 thymeleaf 的新手,最近我想弄清楚如何从字符串中删除特殊字符。以下(粗体文本)代码对我有用,但“单引号”除外:

{ #strings.toLowerCase(#strings.replace(#strings.replace(#strings.replace(name, '\'' ,'-'), '&',''),' ','-'))}

我尝试使用 &apos 和 \' 但不工作。我经历了百里香预处理,但无法从中获得任何帮助。有什么办法吗?

标签: thymeleaf

解决方案


这对我有用:

${#strings.toLowerCase(#strings.replace(#strings.replace(#strings.replace(name, '''','-'), '&',''),' ','-'))}

推荐阅读