How to assign more than one attribute to the html element with thymeleaf

html, spring-mvc, thymeleaf

Solution

Found it! And it works. It should be separated by comma.

HTML forbids repeated attributes, so that code is not correct. However, th:attr and data-th-attr allow you to specify several attributes separated by commas, like:

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

found it on this discussion: https://github.com/thymeleaf/thymeleaf/issues/93

Problem

I have a select box on my thymelaf page. I already have defined one attribute for it like: ``` th:attr="labelId='associateTSF' + ${mViewStat.index}" ``` Is there a way to set more than one? something like: ``` th:attr="labelId='associateTSF' + ${mViewStat.index}; missionGroup=${mView.missionGroup}" ``` I have already tried this with ; and with blank space, no success. All examples I have found are with single value. Thanks!

Original source