springboot 静态文件夹

发布时间 2023-04-21 09:00:53作者: 人间春风意

正常这个很久了,不需要写,但是好几年没有写这个相关的,都忘了,好记性不如烂笔头

 

spring:
  resources:
    static-locations: file:D:\\test       #对应服务器内映射的实际路径
  mvc:
    static-path-pattern: /test/**         #对应服务访问时的前缀
  servlet:
    multipart:
      enabled: true
      max-file-size: 100MB
      max-request-size: 100MB
server:
  port: 80

如:访问http://localhost/test/xx.txt

会获取D盘test文件夹下的xx.txt文件