1、配置自定义拦截器

/**
* Copyright (C), 2017-2018, XXX有限公司
* FileName: WebConfig
* Author: 丶Zh1Guo
* Date: 2018/11/22 16:34
* Description:
* History:
* <author> <time> <version> <desc>
* 作者姓名 修改时间 版本号 描述
*/
package com.example.demo.interceptor; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /**
* 〈一句话功能简述〉<br>
* 〈配置静态资源路径〉
*
* @author 丶Zh1Guo
* @create 2018/11/22
* @since 1.0.0
*/ @Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/");
registry.addResourceHandler("/static").addResourceLocations("classpath:/static");
}
}

2、application.yml 文件配置

resources:
static-locations: classpath:/static,classpath:/public,classpath:/resources,classpath:/META-INF/resources

3、引用如下../static/

SpringBoot 静态资源 加载位置的更多相关文章

  1. 【Bug档案01】Spring Boot的控制器+thymeleaf模板 -使用中出现静态资源加载路径不当的问题 -解决时间:3h

    总结 - thymeleaf的模板解析规则不清楚,或者忘了; - 出现bug时,瞎调试, 没有打开NETWORK 进行查看资源的加载情况 - 控制器中的其他代码,可以先注释掉,这样就可以迅速屏蔽掉其他 ...

  2. SpringBoot配置文件的加载位置

    1.springboot启动会扫描以下位置的application.properties或者application.yml文件作为SpringBoot的默认配置文件 --file:/config/ - ...

  3. IDEA中Springboot静态文件加载(热部署)

    Springboot项目静态文件加载 昨天写项目的时候碰到一个问题,就是静态文件css无法读取到项目中,我仔细思考了下,总结了下,可能有两个问题 1.页面未加载更新 这个可能性非常大,Chrome就是 ...

  4. Springboot中jar 重复冲突 导致 静态资源加载问题!

    这个jar 其实在common 中也是存在的  ,当时没注意看,就导入进来了,然后  css js 等一些静态资源全部不能加载!具体原因我没去深挖!后面找个时间深挖下,先填坑!

  5. Springboot:静态资源加载(七)

    WebMvc自动配置: 搜索WebMvcAutoConfiguration自动装配类: 第一种方式通过webjars加载静态资源: https://www.webjars.org(通过maven加载依 ...

  6. SpringMvc静态资源加载出错

    使用mvc:resource配置 web.xml配置是rest风格的/ 服务器启动没问题 访问地址是报404 另外用了default-servlet的方法加载,服务器启动没错,jsp页面加载静态资源要 ...

  7. springMVC servlet 静态资源加载

    问题描述 新手使用SpringMVC时市场会遇到静态资源无法加载在问题,如下图所示 问题原因 出现这种问题一般是在web.xml中的对spring的DispatcherServlet采用了如下配置,即 ...

  8. 关于web项目中静态资源加载不了的一些解决思路

    问题的产生: <!--springMVC前端控制器加载--> <servlet> <servlet-name>springmvc</servlet-name& ...

  9. spring boot的静态资源加载

    1.spring boot默认资源处理 Spring Boot 默认为我们提供了静态资源处理,使用 WebMvcAutoConfiguration 中的配置各种属性. spring boot默认加载文 ...

随机推荐

  1. rest_framework 权限功能

    权限: 问题:不用视图不用权限可以访问 基本使用 写上一个权限类 创建utils 中 permission.py文件 class SvipPermisson(object): message = &q ...

  2. Lists and tuples

    zip is a built-in function that takes two or more sequence and ‘zips’ them into a list of tuples, wh ...

  3. String build-in function - len

    len is a build-in function that returns the numbers of characters in a string: Since we started coun ...

  4. Saying Good-bye to Cambridge Again

    Saying Good-bye to Cambridge Again Very quietly I take my leave,      As quietly as I came here;     ...

  5. <Sicily>Inversion Number(线段树求逆序数)

    一.题目描述 There is a permutation P with n integers from 1 to n. You have to calculate its inversion num ...

  6. vue1.0父子、兄弟间 通信案例

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. Linux企业运维人员最常用150个命令汇

    近来老男孩发现新手学习Linux记不住命令,不会分类.不会筛选重点,胡子眉毛一把抓当然记不住了. 特别整理Linux运维最常用150个命令和大家分享,大家学习命令不用在盲目了,根据分类,然后逐步学习! ...

  8. MySQL服务正在启动或停止中,请稍候片刻后再试一次【解决方案】

    相信有些小伙伴在使用数据库的过程中会经常频繁的启动和停止MySQL服务,有时候会出现“服务正在启动或停止中,请稍候片刻后再试一次.”这样的提示,如下图所示. 于是乎想办法去解决这个问题,但是发现连强制 ...

  9. caffe(5) 其他常用层及参数

    本文讲解一些其它的常用层,包括:softmax_loss层,Inner Product层,accuracy层,reshape层和dropout层及其它们的参数配置. 1.softmax-loss so ...

  10. ES6学习笔记(十九)Module 的语法-export和import

    1.概述 历史上,JavaScript 一直没有模块(module)体系,无法将一个大程序拆分成互相依赖的小文件,再用简单的方法拼装起来.其他语言都有这项功能,比如 Ruby 的require.Pyt ...