package com.hc.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${setting.uploadPath}")
    public String uploadPath;
    @Value("${setting.downloadPath}")
    public String downloadPath;

    /**
     * 映射文件路径
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/**","/download/**")
                .addResourceLocations("file:"+uploadPath,"file:"+downloadPath);
    }
}
