【发布时间】:2020-10-24 21:37:54
【问题描述】:
我使用 spring boot 2.3.1.RELEASE 将spring-boot-starter-thymeleaf 依赖项添加到我的项目中,并将error.html 文件放在src/main/resources/templates 中,名称为error.html and other custom error pages inside src/main/resources/templates /error` 如下图所示:
并在 application.yml 中添加此配置:
server:
error:
whitelabel:
enabled: false
并通过将@SpringBootApplication(exclude = {ErrorMvcAutoConfiguration.class}) 添加到Application 类中来排除ErrorMvcAutoConfiguration。
但是,不幸的是,当发生错误时,我会在下面看到这个页面,例如 404 错误!
我该如何解决这个问题?我也用谷歌搜索过,但没有找到任何帮助。
【问题讨论】:
标签: java spring spring-boot error-handling customization