正确写法:
<a href="#" class="btn btn-info" data-toggle="modal" th:onclick="showmodel([[${stu.stuId}]])" data-target="#myModal">修改</a>
th:οnclick="showmodel([[${stu.stuId}]])"
错误写法:
1.th:οnclick="|showmodel('${stu.stuId}')|"
报500错误,控制台报错:
org.thymeleaf.exceptions.TemplateProcessingException: Only variable expressions returning numbers or booleans are allowed in this context, any other datatypes are not trusted in the context of this expression, including Strings or any other object that could be rendered as a text literal. A typical case is HTML attributes for event handlers (e.g. "onload"), in which textual data from variables should better be output to "data-*" attributes and then read from the event handler. (template: "adminStuUser.html" - line 47, col 63)
2.th:οnclick="showmodel('${stu.stuId}')"
不报错,但不会解析${stu.stuId},会把它当作一个字符串