在使用th:onclick传字符参数的时候,报如下错误
Caused by: org.attoparser.ParseException: 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.
有人说是spring-boot版本的问题,升级版本就可以解决,当前版本2.2.1.
<a th:οnclick="'update('+${data.id}+','+${data.name}+');'" >修改</a>
解决办法:
<a th:οnclick="update([[${data.id}]],[[${data.name}]])" >修改</a>