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/",前后端分离的项目用不到该配置

  • 相关阅读:
    ubuntu 10.04安装增强功能 共享文件夹
    CRF简介入门
    Ant 的build.xml 详解
    eclipse中各种颜色和背景的设置
    第13章 类继承 --抽象基类
    第13章 类继承
    团队开发之绩效考核二
    站立会议
    团队站立会议
    团队开发站立会议
  • 原文地址:https://www.cnblogs.com/zou-rong/p/12565036.html
Copyright © 2011-2022 走看看