Home  >  Q&A  >  body text

Thymeleaf cannot parse URL query parameters

<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粉619896145P粉619896145432 days ago416

reply all(1)I'll reply

  • P粉762730205

    P粉7627302052023-08-15 12:45:13

    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>
    

    reply
    0
  • Cancelreply