版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_16855077/article/details/84876309
1.spring boot从classpath/static目录访问
1.1图片测试
通过网址访问图片,测试发现,访问没有问题(注意:默认端口是8080)。
1.2 网站测试
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
Hello spring boot!!!!!<br/>
<img alt="" src="images/1.jpg">
</body>
</html>
访问效果图:
2.通过servletContext访问
在main下创建webapp(一定要是webapp)
测试发现为webapp时,就能访问静态资源,为其他名字时,就无法访问。