thymeleaf使用实例


map取值遍历,dicts为map类型。 

 

报错处理

2020-07-08 16:09:09.189 ERROR 14376 --- [nio-8083-exec-2,,,,] org.thymeleaf.TemplateEngine : [THYMELEAF][http-nio-8083-exec-2] Exception processing template "org/orgConfig": Exception evaluating SpringEL expression: "oc.systemCode" (org/orgConfig)
2020-07-08 16:09:09.192 ERROR 14376 --- [nio-8083-exec-2,,,,] 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.TemplateProcessingException: Exception evaluating SpringEL expression: "oc.systemCode" (org/orgConfig)] with root cause

org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'systemCode' cannot be found on null

1.注意对象是否为空

2.注意命名是否冲突,是否正确

3.遍历内容多时,可以通过删除排查报错行

4.看下html标签是否符合规范,我的出现问题的原因是table里,tr外卖套了div循环,后来改成tbody就可以了。唉,这个问题坑了我一天。