2017-10-17 105 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