Thymeleaf cannot parse URL query parameters
P粉619896145
P粉619896145 2023-08-14 15:57:04
0
1
475
<p>I'm using Thymeleaf version 2.1.4 and I want to print a string when sending query parameters to the URL. But it prints a string object, like this <code>[Ljava.lang.String;@767a8ed5</code>. I try to print it like this in HTML: </p> <pre class="brush:php;toolbar:false;"><p th:text="${param.message}"></p></pre> <p>The URL is like this: </p> <pre class="brush:php;toolbar:false;">http://localhost:8000/about?message=This is about page.</pre> <p>Appreciate the error in my code and hope for help. </p>
P粉619896145
P粉619896145

reply all(1)
P粉762730205

The Param object returns an array of strings for each parameter, even if the parameter has only one value, which is why you see the object reference [Ljava.lang.String;@767a8ed5. You can access the first element of the array using indexing like this:

<p th:text="${param.message[0]}"></p>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template