在服务器上部署时,弹出引导自定义错误页面不会呈现

问题描述 投票:-1回答:1

根据文档,我为spring boot app 404.html编写了一个自定义错误页面,并将此文件放在src / main / resources / public / error / 404.html中。我的application.properties文件也包含'server.error.whitelabel.enabled = false'。现在在localhost上,这个404.html被渲染,但是当部署在服务器上时,这个页面不会呈现,而是显示tomcat HTTP 404错误页面。任何人都可以建议我如何解决这个问题。

PS:文件404.html,404.css捆绑在服务器上部署的war-WEB文件夹中。

spring-boot tomcat custom-error-pages
1个回答
0
投票

我之前有类似的问题,我只是在我的application.properties文件中添加了这些配置

# Spring
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false

注意:使用此配置。在服务器上部署的应用程序上。这将使您的应用程序在本地弹簧启动时使用时忽略资源(嵌入式tomcat)

© www.soinside.com 2019 - 2024. All rights reserved.