springboot springMVC默认访问的静态资源

springMVC默认静态资源路径为: /resources/static/

classpath的指定:org.springframework.boot.autoconfigure.web.ResourceProperties

@ConfigurationProperties(
    prefix = "spring.resources",
    ignoreUnknownFields = false
)
public class ResourceProperties implements ResourceLoaderAware {
    private static final String[] SERVLET_RESOURCE_LOCATIONS = new String[]{"/"};
    private static final String[] CLASSPATH_RESOURCE_LOCATIONS =
                    new String[]{"classpath:/META-INF/resources/", "classpath:/resources/", 
                                 "classpath:/static/", "classpath:/public/"};
    private static final String[] RESOURCE_LOCATIONS;
    private String[] staticLocations;
    private Integer cachePeriod;
    private boolean addMappings;
    private final ResourceProperties.Chain chain;
    private ResourceLoader resourceLoader; public ResourceProperties() {
        this.staticLocations = RESOURCE_LOCATIONS;
        this.addMappings = true;
        this.chain = new ResourceProperties.Chain();
    }
   //...
}

   resources目录作为classpath,resources/static 同样是作为classpath目录

   现在分别在resources,static目录下放了图片。

源码目录:

编译之后target目录:

项目启动访问情况:

项目启动访问情况:

可以访问的:

                http://localhost:8088/pics/fj.jpg,

                http://localhost:8088/libs/fj1.jpg,

                http://localhost:8088/fj3.jpg

   访问出错的:

                http://localhost:8088/fj4.jpg ,http://localhost:8088/libs/fj2.jpg

  

  >> fj2.jpg,fj4.jpg不在static下面,不能访问

  springMVC默认静态资源路径为 /resources/static/

转载于:https://my.oschina.net/u/2471663/blog/811940

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值