1. 程式人生 > 其它 >org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression

org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression

前言

本文中提到的解決方案,原始碼地址在:springboot-thymeleaf,希望可以幫你解決問題。

本文中涉及的兩個異常為我開發時遇到的,可能和你目前所要處理的bug不同,如果不是同一個問題,希望再找找其他文章。

異常

Exception evaluating SpringEL expression這個異常的出現應該有很多原因引起,本文中涉及的兩個異常分別為:

  • org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
  • org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call: Attempted to call method test() on null context object

解決方案

  • 異常1 :
Attempted to call method on null context object

呼叫的方法處於一個空物件中,即呼叫例項為空。

解決方案可以參考我的這篇文章:Method call: Attempted to call method test() on null context object

  • 異常2 :
Method cannot be found

方法不存在

解決方案可以參考我的這篇文章:Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type