一、事件传值
Thymeleaf:如何用 th:onclick 给方法传递参数值
一、th:onclick= "|javascript:edit('${noticemodel.mid}')|"
二、th:onclick= "|edit(${noticemodel.mid})|"

二、解决script引用 ,引用型变量,解析Object内存地址解析失败
var 变量名 = [[${后台保存变量}]]

三、值为null时报错
![]()
2020-11-12 22:55:06.613 ERROR 12280 --- [p-nio-80-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/user/edit.html]")] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method getId() on null context object
at org.springframework.expression.spel.ast.MethodReference.throwIfNotNullSafe(MethodReference.java:154) ~[spring-expression-5.2.10.RELEASE.jar:5.2.10.RELEASE]
解决方案:
加上"?"
四、thymeleaf标签中的值爆红
![]()
解决方案:
开头加上:<!--suppress ThymeleafVariablesResolveInspection -->
说明:以上均是自己踩过的坑,忘各位少走弯路。。。
版权声明:本文为qq_45056878原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。