Found solution, needed quotes around #my_modal_
th:attr="data-target='#my_modal_'+${myObject.id}"
Question
I am using special character '#' as follows:
th:attr="data-target=#my_modal_+${myObject.id}"
This fails with error because of special character '#'
Could not parse as assignation sequence
If i remove '#' it doesnt throw error but doesn't work as intended.
Solution
Found solution, needed quotes around #my_modal_
th:attr="data-target='#my_modal_'+${myObject.id}"
OTHER TIPS
In your HTML change id="my_modal" to class="my_modal"
Then you could do something like
th:attr="data-target=.my_modal_+${myObject.class}"
By using a class which in CSS uses a "." instead of a "#" this should hopefully resolve the issue.