@RequestParam注解有三个参数分别是: value、 required、 defaultValue
resources资源springboot默认只映射static、 template两个文件夹下的文件
如果我们要在resources下新建一个image资源,想要让spring boot找到它,只需在项目主类中配置一下就好
@SpringBootApplication
public class MyApplication extends WebMvcConfigurerAdapter{
public static void main(String[] args){
SpringApplication.run(MyApplication.class,args);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
super.addResourceHandlers(registry);
//这种方式会在默认的基础上增加,不会影响默认的方式
registry.addResourceHandler("/image/**").addResourceLocations("classpath:/image/");
}
}参考资料 http://www.mamicode.com/info-detail-2154485.html