1、配置工程访问路径映射本地路径;
package com.liuyanzhao.chuyun.config; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; /** * @author yhq * @date 2018/2/27 下午3:32 */ @Configuration public class ApplicationConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { //Windows下 registry.addResourceHandler("/uploads2/**").addResourceLocations("file:D:/uploads2/"); //Mac或Linux下(没有CDEF盘符) registry.addResourceHandler("/uploads/**").addResourceLocations("file:/Users/uploads/"); super.addResourceHandlers(registry); } }
原文地址:https://www.cnblogs.com/yuhuiqing/p/10713791.html
时间: 2024-10-07 09:27:18