-1

I read many URLs from database through Java Spring Boot and thymleaf expression. And if the URL has "?" it changed automaticaly to "%3F" for instance the URL: www.myserver.de?id=3 will be www.myserver.de%3Fid=3 I think I can't use this solution link because the URLs are readen from DB with Params

< a th:href="@{//{link}(link=${link})}" target="_blank"> For more information click here < /a >

3 Answers3

0

Your URLs are url encoded in the database so ? is represented as %3F. If you want to get the original URL from encoded URL you need to url decode it e.g. by doing:

String result = java.net.URLDecoder.decode(url, StandardCharsets.UTF_8);
Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
0

You can decode it back to what was your original url.

If you are using java use java.net.URLDecoder.

More here

YoManTaMero
  • 391
  • 4
  • 10
0

If you are just reading complete URLs straight from the database, you shouldn't be using Thymeleaf standard url syntax (as it's designed to escape URL parameters). You should just do something like:

<a th:href="|//${link}|" target="_blank">For more information click here</a> 
Metroids
  • 18,999
  • 4
  • 41
  • 52