Whitelabel Error Page

原文链接:https://www.longkui.site/error/whitelabel-error-page/5266/
某天创建一个springboot项目练练手,访问接口的时候开始报错:

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Thu Dec 29 11:01:11 CST 2022
There was an unexpected error (type=Internal Server Error, status=500).

而且这个报错调试了一下,能进后台断点,只是返回的时候开始报错:

然后百度了很多解决方法,最终解决了这个问题,这篇文章简单总结一下出现这个问题的原因和解决方法。

注意1:页面上显示这个这个报错,原因不唯一,很多方面的原因都可能造成这个问题,我只记录了我实际遇到的。

注意2:这个报错是500,不是“There was an unexpected error (type=Not Found, status=404)”如果是404,请先检查一下启动类的位置对不对。

原因1:注解问题
有的时候写代码会忘了某些注解,比如@ResponseBody,这个时候可能控制台一般会报错:

Exception processing template “students/getList”: Error resolving template [students/getList], template might not exist or might not be accessible by any of the configured Template Resolvers

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [students/getList], template might not exist or might not be accessible by any of the configured Template Resolvers

可以参考下面这篇文章解决:

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [students/getList], template might not exist or might not be accessible by any of the configured Template Resolvers

原因2:数据格式问题
控制台会报错类似下面:

Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: java.time.LocalDateTime cannot be cast to java.lang.String; nested exception is com.fasterxml.jackson.databind.JsonMappingException: java.time.LocalDateTime cannot be cast to java.lang.String (through reference chain: java.util.ArrayList[0]->java.util.HashMap[“update_time”])]

可以参考下面这篇文章进行解决:

Resolved [org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON:

原因3:xml写错
这个主要是xml文件写错了,一般控制台会给出比较明显的提示,比如下面这样:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘})’ at line 3

The error may exist in file [D:\项目\springboot\app\target\classes\mappers\StudentsMapper.xml]

The error may involve defaultParameterMap

The error occurred while setting parameters

SQL: INSERT INTO students (stu_name, stu_sex, class_id, age) VALUES ( ?, ?, ?, {age});

Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘})’ at line 3

; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘})’ at line 3] with root cause
很明显,下面这个地方写错了,要加上#变成 #{age}才行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
白标错误页面是指在网络应用或网站上,当用户请求的页面无法找到或发生错误时,显示的一个通用错误页面。它通常是为了增加用户体验和品牌一致性而设计的。 白标错误页面与传统的错误页面不同之处在于,它采用了品牌的设计元素和相关的信息,以使用户在遇到问题时感觉更加熟悉,并提供帮助或引导用户解决问题。 白标错误页面通常包括以下几个要素: 1. 品牌标识:页面上会显示网站或应用的Logo或名称,以确保用户知道他们仍然在正确的网站上; 2. 错误信息:页面会提供简洁明了的错误信息,告诉用户发生了什么问题,例如404页面不存在或500服务器错误等; 3. 导航或搜索栏:为了帮助用户继续浏览网站或应用,页面上会提供一个导航栏或搜索框,让用户轻松找到他们想要的内容; 4. 联系信息或帮助资源:页面上会提供联系信息或者链接到常见问题解答或帮助文档,以便用户可以寻求进一步的帮助; 5. 友好的语言和设计:白标错误页面通常使用友好和亲切的语言,以及与品牌一致的设计风格,产生一种给予用户支持和关怀的感觉。 总而言之,白标错误页面是通过将品牌元素与错误信息结合,以提供更好的用户体验和支持。它帮助用户理解问题的原因,并提供帮助和解决方案,以确保用户能继续使用网站或应用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值