Search code examples
javaspring-mvcspring-bootthymeleaf

I thymeleaf how to use page parameter as property key?


There is such redirection in Controller:

return "redirect:login?message=login.registered";

In html template I want to show property's value for login.registered key.

In jsp it was just:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
...
<spring:message code="${param.message}"/>

How to do the same using Thymeleaf?


Solution

  • I think in thymeleaf, you can do this with the #messages object. This should work:

    <div th:text="${#messages.msg(param.message)}" />