统一异常管理:报错EL1007E: Property or field 'message' cannot be found on null
根据博客教程 http://blog.didispace.com/springbootexception/ 编写demo,启动应用访问 http://localhost:8080/hello 报错:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "exception.message" (error:10)
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "exception.message" (error:10)
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'message' cannot be found on null
解决办法:在Contoller中要添加一个抛出异常: