I want to display the characters of the escape sequence in my browser.

Asked 1 years ago, Updated 1 years ago, 116 views

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

2022-09-30 18:09

2 Answers

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 &yen; have no particular meaning in general strings, and they are probably escaped like &yen; when generating HTML.

Instead of using entity references, you can enter the letter U+00A5 directly.

String disp=text.replaceAll("\\\", "\u00A5");


2022-09-30 18:09

"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


2022-09-30 18:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.