2017-10-17 70 views
0

我想要替换我的thymeleaf模板中的单引号(')字符。由于我们的编码是逃避到'和客户端期望它是'越来越异常评估SpringEL表达式:错误在thymeleaf

为了实现快速修复,我打算用一个空格替换所有出现的有效载荷中的单引号(')字符。但是,这样做,我收到以下错误:

Exception evaluating SpringEL expression:

我已经使用的替换表达式:

<th:block th:with="Description=${op.jpText('$.short_description')}"> 
    <u_short_description th:text="${#strings.replace(Description,''',' ')}"></u_short_description> 
</th:block> 

任何帮助将高度赞赏。提前致谢!

+0

可能重复[如何在Thymeleaf中单引号(')转义](https://stackoverflow.com/questions/43121788/how-to-escape-single-quote-in-thymeleaf) – Metroids

回答

0

应该

<th:block th:with="Description=${op.jpText('$.short_description')}"> 
    <u_short_description th:text="${#strings.replace(Description,'''',' ')}" /> 
</th:block> 

你是不是正确的逃逸单引号在replace