Sunday, 15 September 2013

html - Using model attributes in a th:href link -


Is there a way to refer to a model attribute in the th: href link? For example

  & lt; A th: text = "$ {currentUser}" th: href = "@ {/ user / {currentUser}}" & gt; & Lt; / A & gt;  

Here, currentUser is a model variable specified in a controller. It can be seen in the th: text tag. However, th: href thymeleaf parsing fails If there is a way to refer to a model feature like this, in th: href ? For reference, this is a Spring MVC (bootstrap) application with Thiamelfl support. Model Variables in th: href You can call it $ { ...} to be included with the indicator, you can add the pipe easily by adding:

  & lt; A th: text = "$ {currentUser}" th: href = "@ {| / user / $ {currentUser} |}" & gt; & Lt; / A & gt;  

Official document on url syntax.


No comments:

Post a Comment