做web项目时候有大量的html,css,js,图片等静态资源需要加载访问

springboot中默认的webapp下的文件可以直接访问

springboot静态资源访问

访问 http://127.0.0.1:8080/static/pic/1.jpg 可以打开图片

访问 http://127.0.0.1:8080/1.jpg 也可以打开图片

 

Spring Boot默认提供静态资源目录位置需置于classpath下,目录名需符合如下规则:

  • /static
  • /public
  • /resources
  • /META-INF/resources
  • 比如我在java/main/resources/下建了文件夹static下面放了2.jpg 下面就是访问结果

访问 springboot静态资源访问

 

相关文章:

  • 2021-12-24
  • 2021-12-23
  • 2021-11-20
  • 2021-11-20
猜你喜欢
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-20
  • 2021-11-15
  • 2021-08-01
相关资源
相似解决方案