package com.ruoyi.framework.config;
import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.CacheControl;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* 通用配置
*
* @author ruoyi
*/
@Configuration
public class ResourcesConfig implements WebMvcConfigurer
{
@Autowired
private RepeatSubmitInterceptor repeatSubmitInterceptor;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
/* Constants.RESOURCE_PREFIX + "/**":这个路径模式表示所有以/resource/开头的请求都会被映射到本地文件系统。
addResourceLocations("file:" + RuoYiConfig.getProfile() + "/"):指定了这些静态资源在本地文件系统中的位置。RuoYiConfig.getProfile()获取了配置中的文件上传路径。
举例来说,如果Constants.RESOURCE_PREFIX是/resource,而RuoYiConfig.getProfile()返回的是/uploads,那么访问/resource/image.jpg将会映射到本地文件系统的/uploads/image.jpg。*/
/** 本地文件上传路径 */
//public static final String RESOURCE_PREFIX = "/resource";
registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
.addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
}
}
网友评论