Spring Boot Failed to load resource: the server responded with a status of 404 ()

Posted --- 锅老官扎起哦!

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring Boot Failed to load resource: the server responded with a status of 404 ()相关的知识,希望对你有一定的参考价值。

出现错误:

Failed to load resource: the server responded with a status of 404 ()

但是其他页面正常显示:

 

原因:

浏览器看一下: 

 

 

点开 看一下 请求链接:

 

Request URL: http://localhost:8080/emp/asserts/css/bootstrap.min.css 
 
明显 加了 请求关键字 emp 了. 
 
但是我们的资源路径全部放在 static 应该没有问题,拦截器如果存在问题,那其他页面也不可能正常显示<
 
 

处理办法:

加上反斜杠

  <script type="text/javascript" src="/asserts/js/jquery-3.2.1.slim.min.js"></script>
    <script type="text/javascript" src="/asserts/js/popper.min.js"></script>
    <script type="text/javascript" src="/asserts/js/bootstrap.min.js"></script>

或者使用thymeleaf @{}处理

 <script type="text/javascript" src="asserts/js/feather.min.js" th:src="@{/asserts/js/feather.min.js}"></script>

 

 

 

 

以上是关于Spring Boot Failed to load resource: the server responded with a status of 404 ()的主要内容,如果未能解决你的问题,请参考以下文章

解决 spring boot Failed to decode downloaded font

解决 spring boot Failed to decode downloaded font

自定义spring-boot-autocofigure使用maven打包的时候报错了:Failed to execute goal org.springframework.boot:spring-bo

Spring boot 2.0.3.RELEASE, Spring data rest, application error, failed to start

Spring boot打包报错:Failed to execute goal org.apache.

maven打包异常-Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.1.RELEAS