一、继承WebMvcConfigurerAdapter,重写addResourceHandlers,在registry里面配置访问路径和映射到的服务器本地路径。

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter{ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("/file/static/*").addResourceLocations("file:E:\\springboot\\");
} }

结果如图:

在上述配置中,访问file/static/下的文件会被映射到本地项目E:\\springboot\\下的目录里面。

最新文章

  1. 在Linux主机上搭建SVN,用于同步提交修改,实现本地提交线上预览(SVN Hook功能实现)
  2. idhttp的用法
  3. cogs896 圈奶牛
  4. php-fpm的重启/关闭
  5. C语言文件函数
  6. android测试的相关概念以及单元测试
  7. EJB理解
  8. Bzoj 3171: [Tjoi2013]循环格 费用流
  9. C# 内存管理优化畅想(一)---- 大对象堆(LOH)的压缩
  10. 201512读书分享——读《做自己的No.1》“哪一天”是永远不会到来的
  11. TCP跟UDP乱侃
  12. nginx匹配规则说明以及匹配的优先级
  13. mysql中利用show profile很直观的看到查询缓存的作用。
  14. BUG——Celery ValueError: not enough values to unpack
  15. jQuery 文件上传插件:uploadify、swfupload
  16. linux -- Ubuntu报错“unable to locate package...”
  17. APP消息推送功能
  18. hdu6121 build a tree(树)
  19. TCO 2015 Round 2A DIV1
  20. iOS define 宏定义 和 const定义常量区别

热门文章

  1. Linux-TCP之深入浅出send和recv【转】
  2. Java jdom解析xml文件带冒号的属性
  3. 关于tomcat setenv
  4. 在Rust中,cargo使用国内镜像源
  5. github配置ssh及多ssh key问题处理
  6. 使用DRF来快速实现API调用服务
  7. you have new mail in /var/spool/mail/root !
  8. 20191031 牛客网CSP-S Round2019-2
  9. Vue 变异方法filter和正则RegExp对评论进行搜索
  10. 封装cookie的设置和获取