美文网首页
记录springboot遇到的一些错误

记录springboot遇到的一些错误

作者: 逝去丶浅秋 | 来源:发表于2020-12-28 16:49 被阅读0次

一、关于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

<script>
    var user = [[${user}]];
    alert(user)
</script>

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

相关文章

网友评论

      本文标题:记录springboot遇到的一些错误

      本文链接:https://www.haomeiwen.com/subject/hmktoktx.html