0

I am preparing Product Quotation so I want to display Currency symbol in my Thymeleaf Template

I am using unicode value(HEX) for currency symbol from this website https://www.ip2currency.com/currency-symbol

I have written <p th:utext="${currencySymbol}"/> in my HTML page to display currency symbol but it is not working, here currencySymbol is my thymeleaf variable and it's value is &#x20b9; and I am using Spring Boot

Please Help me, How to dispay currency symbol in thymeleaf template using Unicode

Joris Schellekens
  • 8,483
  • 2
  • 23
  • 54
Ketan Navadiya
  • 279
  • 3
  • 6
  • 18
  • You can see my (incorrectly) downvoted answer as a workaround if you don't want to use the symbols from that website: https://stackoverflow.com/questions/14160304/how-to-format-the-currency-in-html5-with-thymeleaf – riddle_me_this May 31 '18 at 03:28
  • Otherwise, you may need to set the `contentType` on the `ThymeleafViewResolver` to UTF-8 – riddle_me_this May 31 '18 at 03:32
  • Unicode value came from Database, different currency will have different Unicode value So I need to display it. Please Can you tell me that how and where (In which file) I have to set ThymeleafViewResolver ? – Ketan Navadiya May 31 '18 at 04:11
  • You tagged your question with iText but I don't see anything in your question about PDF? Only about HTML? Please clarify. – Amedee Van Gasse May 31 '18 at 04:23
  • from the generated Thymeleaf template I am creating PDF file of it using IText – Ketan Navadiya May 31 '18 at 04:27
  • Then the current question is not iText related. At the moment you are still generating the HTML, and that's where the problem is. – Joris Schellekens May 31 '18 at 08:25
  • Something like this: https://stackoverflow.com/questions/36397203/utf8-charset-with-thymeleaf. There would be similar code for Java config (shown in the external link on that answer). – riddle_me_this May 31 '18 at 19:14

1 Answers1

3

use like this

<span th:utext="${'&#36;'+'&nbsp;'}" ></span></b><span th:text="${p.price}"></span> it is written inside a span tag one span for currency(html of dollar) and another span tag fro dsplaying price from db

KJ KJ
  • 46
  • 2