I want this to output

What up?

But I get i...">

Avoiding a single quotation mark (') in Timeleaf

<h1 th:text="${'What\ up?'}"></h1>

I want this to output

<h1>What up?</h1>

But I get it TemplateInputException. I tried with the HTML object, but it does not work.

+4
source share
3 answers

Double single quote. Like this:

<h1 th:text="${'What' up?'}" />
+10
source

it is possible to use htm ascii code: &#39;

<h1 th:text="${'What&#39;s up&#63;'}"></h1>
0
source

To avoid a single quote, you simply avoid it with \'

<p th:text="'What\ up?'"></p>
<p th:text="${myVar} + 'What\ up?'"></p>
0
source

Source: https://habr.com/ru/post/1673619/


All Articles