Spring Boot 配置映射本地资源访问

位置:首页>文章>详情   分类: 教程分享 > Java教程   阅读(740)   2023-03-28 11:29:14
Spring Boot 配置映射本地资源访问

注意配置为两个
spring.mvc.static-path-pattern=
spring.resources.static-locations=
这两个配置的默认值是:
spring.mvc.static-path-pattern=/**
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ 
解释一下:
这两个的默认配置意思是请求来了 /路径下的,先去找spring.resources.static-locations配置的几个目录下有没用静态的资源文件。访问各个目录的优先级为从左到右由高到低。


问题来了,我们如果想添加一个本地的绝对路径映射该怎么配置呢?
spring.resources.static-locations=classpath:/static,D:/share
w我最初以为这样就可以了,然而后面的配置并没有生效。。。。。

注意!注意!注意!要像下面这样配置才能生效。
spring.resources.static-locations=classpath:/static,file:D:/share
标签: Spring Boot
地址:https://www.leftso.com/article/657.html

相关阅读

引言    通过之前spring boot mybatis 整合的讲解: spring boot mybaties整合  (spring boot mybaties 整合 基于Java注解方式写...
Spring Boot 2.0,Spring框架的Spring Boot 中的Spring Boot Actuator变化讲解。并且了解如何在Spring Boot 2.0中使用Actuator...
Spring Boot 2.0 绑定properties属性资源文件 Spring Boot 2.0 读取properties配置文件值 Spring Boot 2.0获取properties配...
spring boot入门,spring boot是一个崭新的spring框架分支项目,本文讲解其属性配置相关
spring boot 1.5整合redis实现spring的缓存框架,spring boot,redis
spring boot是一个崭新的spring框架分支项目,本文讲解基本的数据库配置
Spring Boot validation整合hibernate validator实现数据验证,Spring Boot validation使用说明,Spring Boot validat...
spring boot mybatis 整合使用讲解介绍,spring boot与mybaties的使用讲解介绍。spring boot mybatis xml mapper方式的入门和通过一个...
spring boot又一个spring框架的经典项目,本文讲解spring boot入门的环境配置以及第一个项目,Spring Boot 入门教程
Spring Boot 2.0 Redis整合,通过spring boot 2.0整合Redis作为spring缓存框架的实现。