html - Spring 引导未加载

标签 html css spring

我将一些 Bootstrap 模板粘贴到我的资源/模板文件夹中,当我启动服务器并转到我将 index.html 页面映射到的 url 时,页面加载但 Bootstrap 丢失。当我使用 IntelliJ 中出现的 chrome 按钮查看您的 html 时,它正常工作, Bootstrap 加载并且一切正常。 示例:

在我的 index.html 页面中:

<link  rel="stylesheet" href="bootstrap.css">

enter image description here

在这里你可以清楚地看到它们(index.html 和 bootstrap.css)在同一个文件夹中。那么为什么当我启动 spring 应用程序并转到 url 我得到 html 页面和这个错误:

GET http://localhost:8080/bootstrap.css net::ERR_ABORTED 404

错误发生在第 14 行,第 14 行是:

  <link  rel="stylesheet" href="bootstrap.css">

最佳答案

Static resources should go under static folder

enter image description here

请将 bootstrap.css 复制到 static 文件夹下。

关于html - Spring 引导未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55110332/

相关文章:

jquery - 找到 div 高度问题并相应地更改边距

javascript - 试图改变 <a> 标签的 href

jquery - jQuery用大量数据填充选项标签会使浏览器崩溃

javascript - 除非来自文件本身,否则 css 无法从 .css 文件工作

java - Thymeleaf: th:each 代表两个表行?

java - GWT。删除 anchor 部分 url

javascript - 如何针对不同的屏幕尺寸更改语义 UI 侧边栏的位置?

html - List Numbering style CSS, Right Numbering like Arabic Numbering 系统

spring - grails自定义验证器:强制无消息

java - 通讯链路故障 : Connection reset with C3P0