简体   繁体   中英

Parsing special character in thymeleaf text template

I am using Thymelead Text Temaplate, and want to parse special character like single quote, '&' etc. I am trying like [# th:text="${'What''s up?'}" /] but it is throwing following error:

ERROR a.c.s.d.o.h.c.SubmissionController - Exception evaluating OGNL expression: "'What''s up?'" (template: "sample-template" - line 63, col 4)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "'What''s up?'" (template: "sample-template" - line 63, col 4)

Your code is fine. This, for example, works for me:

<p th:inline="text">
    [# th:text="${'What''s up?'}" /]
</p>

Possibly there is something wrong with how Thymeleaf evaluates that your code is text.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM