The Springboot controller is trying to display the values converted below in HTML5.
String text="\100."
String disp=text.replaceAll("\\\", "¥");
→"¥100."
I want to display this on the HTML5 side, but it doesn't change...
¥100.
appears.
<div class="start-message">
<spanth:id="disp" th:text="${disp}">/span>
</div>
Is there any good way?
java spring-boot thymeleaf
I don't know anything about Spring Boot, but the variable text
and disp
are probably just strings, not sources of HTML.HTML entity references ¥
have no particular meaning in general strings, and they are probably escaped like ¥
when generating HTML.
Instead of using entity references, you can enter the letter U+00A5 directly.
String disp=text.replaceAll("\\\", "\u00A5");
"I don't think ""yen"" has any special meaning in HTML, so I think you can just include it as it is, as int32_t replied."
If you want to insert HTML meaningful symbols and body references directly into HTML without escaping them, you will have to use them because each template has a method.
If you want Thymeleaf to display the XHTML tag without escaping, you must use a different attribute: th:utext (for "unescaped text"):
Text Without Escape
© 2024 OneMinuteCode. All rights reserved.