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!

有帮助吗?

解决方案

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

其他提示

This worked for me

th:attr="attrParam1=${attrVal1}, 
         width=${width != null ? width : null}, 
         height=${height != null ? height : null}"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top