當(dāng)前位置:
首頁 >
Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()
發(fā)布時間:2025/3/12
29
豆豆
生活随笔
收集整理的這篇文章主要介紹了
Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
Springboot 頁面訪問不到靜態(tài)資源
問題:在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設(shè)置靜態(tài)資源的訪問路徑
# 只有靜態(tài)資源的訪問路徑為/static/**時,才會處理請求 spring.mvc.static-path-pattern=/static/**重新啟動后、完美解決問題
總結(jié)
以上是生活随笔為你收集整理的Springboot 页面访问不到静态资源Failed to load resource: the server responded with a status of 404 ()的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 用友二次开发_详解ERP系统与MES系统
- 下一篇: JavaScript 中的 window