记录springboot遇到的一些错误

一、关于Thymeleaf的错误

1、An exception was raised while trying to serialize object to JavaScript using Jackson

报错信息如下:

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/list.html]")
Caused by: org.attoparser.ParseException: An error happened during template rendering
Caused by: org.thymeleaf.exceptions.TemplateOutputException: An error happened during template rendering
Caused by: org.thymeleaf.exceptions.TemplateOutputException: An error happened during template rendering
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: An exception was raised while trying to serialize object to JavaScript using Jackson
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: 
    No serializer found for class java.util.logging.ErrorManager and no properties discovered to create BeanSerializer 
    (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS)

报错分析:
(1)主要需要注意两个错误信息:

  • An exception was raised while trying to serialize object to JavaScript using Jackson
  • to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS

(2)引起这种报错的原因有很多,我这里出现的问题是在Thymeleaf模版页面里使用[[${user}]]获取user,因为后台没有传过来user,user是空的,所以报错,报错推荐解决方案是:禁用SerializationFeature.FAIL_ON_EMPTY_BEANS


解决方案:将报错分析中(2)出现错误的地方删掉,如果可以获取到则不会报错。

你可能感兴趣的:(记录springboot遇到的一些错误)