SpringBoot-自定义处理静态资源

静态资源路径 是指系统可以直接访问的路径,且路径下的所有文件均可被用户直接读取。
在Springboot中默认的静态资源路径有:classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,从这里可以看出这里的静态资源路径都是在classpath中
自定义目录
Spring Boot默认是使用resources下的静态资源进行映射。如果我们需要增加以 /myres/* 映射到 classpath:/myres/* 为例的代码处理为: 实现类继承 WebMvcConfigurerAdapter 并重写方法 addResourceHandlers
package org.hsweb.demo.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
* Created by 11 on 2017/4/17.
@Configuration
public class WebAppConfigurer extends WebMvcConfigurerAdapter {