由于spring Boot是内置tomcat的,所以无法用之前的设置虚拟路径的方式进行设置,spring Boot提供了方便的配置方案,只需要在配置文件中配置就可以.
具体代码:
web.img-path=E:/zhangzd/petfishphotos/ //自定义属性,以/结尾
spring.mvc.static-path-pattern=/** //所有的访问都经过静态资源路径;
spring.resources.static-locations= //配置静态资源路径
classpath:/META-INF/resources/,classpath:/resources/,\
classpath:/static/,classpath:/public/,file:${web.img-path}
参考自:http://blog.youkuaiyun.com/kilua_way/article/details/54601195
本文介绍如何在Spring Boot中配置静态资源路径,包括使用内置Tomcat时的虚拟路径设置方法。通过配置文件指定静态资源的位置,实现所有访问请求均经过设定的静态资源路径。
816

被折叠的 条评论
为什么被折叠?



