问题:
在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/**
重新启动后、完美解决问题 bing~go~