zoukankan      html  css  js  c++  java
  • SpringBoot配置访问静态资源

    application.yaml

    server:
    servlet:
    #拦截路径
    context-path: /
    #端口
    port: 8088
    logging:
    level:
    #日志级别,目录: 级别
    com.company: debug

    org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration.java中有

    @Configuration(proxyBeanMethods = false)
    @Import(EnableWebMvcConfiguration.class)
    @EnableConfigurationProperties({ WebMvcProperties.class, ResourceProperties.class })
    @Order(0)
    public static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer {

    点进去ResourceProperties.class

    @ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
    public class ResourceProperties {

    private static final String[] CLASSPATH_RESOURCE_LOCATIONS = { "classpath:/META-INF/resources/",
    "classpath:/resources/", "classpath:/static/", "classpath:/public/" };

    /**
    * Locations of static resources. Defaults to classpath:[/META-INF/resources/,
    * /resources/, /static/, /public/].
    */
    private String[] staticLocations = CLASSPATH_RESOURCE_LOCATIONS;

    一般使用"classpath:/static/",前后端分离的项目用不到该配置

  • 相关阅读:
    JS——switch case
    JS——“==”与“===”
    C#——枚举格式转换与比较
    XML——读与写
    SQl基本操作——try catch
    JS——indexOf replace search
    C#——数据库的访问
    SQL基本操作——存储过程
    C#——设置开机启动
    C#——计时器的操作
  • 原文地址:https://www.cnblogs.com/zou-rong/p/12565036.html
Copyright © 2011-2022 走看看