registry.addResourceHandler(“/front/**“).addResourceLocations(“classpath:/front/“)到底有何作用.
spring boot 指定静态资源路径
·
目前我只知道这玩意加上就能指定静态资源的路径
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/");
registry.addResourceHandler("/back/**").addResourceLocations("classpath:/back/");
}
}
当然还有另一种方法就是写yml文件
l# 配置静态页面资源的访问路径(静态资源不在static目录下就需要i配置)
mvc:
static-path-pattern: /front/**
resources:
# 指定静态资源存放的位置
static-locations: classpath:/front/
如果不指定也行,只要把静态资源放进resources/static目录下就行了
更多推荐
已为社区贡献6条内容
所有评论(0)