当前位置 : 主页 > 编程语言 > c++ >

springboot添加自定义资源

来源:互联网 收集:自由互联 发布时间:2021-07-03
springboot添加自定义资源 @Configurationpublic class ResourceConfig extends WebMvcConfigurationSupport {@Value("${url.proj}")private String resProject;@Overrideprotected void addResourceHandlers(ResourceHandlerRegistry registry) { //指
springboot添加自定义资源
@Configuration
public class ResourceConfig extends WebMvcConfigurationSupport {
	@Value("${url.proj}")
	private String resProject;

	@Override
	protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        //指定目录资源
        registry.addResourceHandler("/data/project/**").addResourceLocations("file:" + resnProject);
        //classpath目录资源
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
      }
}
网友评论