當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()
生活随笔
收集整理的這篇文章主要介紹了
Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Springboot 頁面訪問不到靜態資源
問題:在HTML文件中引入圖片,但是瀏覽器訪問不到圖片。
index.html:
<!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"><head><meta charset="UTF-8"><title>Helllo Jenkins</title> </head> <body><h1 style="text-align: center;">This is my first demo for Jenkins </h1><div align="center"><img th:src="@{/static/doudou.jpg}" style="width: 80%;height: 70%"></div></body> </html>瀏覽器錯誤信息:
Failed to load resource: the server responded with a status of 404 ()
解決方法:
在配置文件application.properties設置靜態資源的訪問路徑
# 只有靜態資源的訪問路徑為/static/**時,才會處理請求 spring.mvc.static-path-pattern=/static/**重新啟動后、完美解決問題
總結
以上是生活随笔為你收集整理的Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用友二次开发_详解ERP系统与MES系统
- 下一篇: Java SSM6——SSM整合