It's almost as written here, but because the JavaScript argument got stuck in a string pattern.
If you want to dynamically embed a value in an attribute value and add text with Thymeleaf3
Escape single quotes with a backslash.
<a href="#" th:attr="onclick='alert(\'aaaa' + ${page} + '\');'" >
Write. At this time, if you insert a space because it is easy to see before and after escaping, the entered space will be faithfully reflected, so be careful.
Recommended Posts