springboot 设置虚拟目录

具体请看 http://www.zslin.com/web/article/detail/23

application.properties或application.yml

#自定义资源目录
#spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:D:/upload/

注意:web.upload-path这个属于自定义的属性,指定了一个路径,注意要以/结尾;

spring.mvc.static-path-pattern=/**表示所有的访问都经过静态资源路径;

spring.resources.static-locations在这里配置静态资源路径,前面说了这里的配置是覆盖默认配置,所以需要将默认的也加上否则staticpublic等这些路径将不能被当作静态资源路径,在这个最末尾的file:${web.upload-path}之所有要加file:是因为指定的是一个具体的硬盘路径,其他的使用classpath指的是系统环境变量

猜你喜欢

转载自wu1g119.iteye.com/blog/2343568