Thymeleaf - custom attribute

前端 未结 3 1444
天命终不由人
天命终不由人 2021-02-05 02:48

I need to set custom attribute (data-validation-matches-message) value from messages resources.



        
相关标签:
3条回答
  • 2021-02-05 03:17

    Since Thymeleaf 2.1 you can do this:

    <a data-th-attr="data-groupid=${somevalue}, data-groupname=${someothervalue}">...</a>
    

    source

    0 讨论(0)
  • 2021-02-05 03:29

    Using 3.0.9.RELEASE:

    <td th:text="${item.description}" th:attr="width=${isSplit} ? '44%' : '59%'" />
    

    This will add width="44%" or width="59%according to a boolean set in the variables. width might as well have been any other custom attribute.

    0 讨论(0)
  • 2021-02-05 03:31

    Try this:

    <input th:attr="data-validation-matches-message='\'' + #{user.notfound}" + '\''"/>
    
    0 讨论(0)
提交回复
热议问题