zoukankan      html  css  js  c++  java
  • 静态文静映射配置

    静态文静映射配置

    方式一:把 excel 模板放到 web_ui 下,访问 http://localhost:8080/static/excel名称 即可下载

    # 这里表示只有静态资源的访问路径为/static/**时,才会处理请求
    spring.mvc.static-path-pattern=/static/**
    #windows 环境
    spring.resources.static-locations=file:C://web_ui/
    #Linux 环境
    spring.resources.static-locations=file:/home/gdop/web_ui/
    

      

     方式二:把 excel 模板放到 resource/static下,访问 http://localhost:8080/pub/excel名称 即可下载

    package com.deallinker.opserver.config;
    
    import org.springframework.context.annotation.Configuration;
    import org.springframework.http.CacheControl;
    import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
    import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
    import org.springframework.web.servlet.resource.EncodedResourceResolver;
    import org.springframework.web.servlet.resource.VersionResourceResolver;
    
    import java.util.concurrent.TimeUnit;
    
    /**
     * @Description: TODO
     * @Author: tangsw
     * @Date 2020/6/2 14:12
     **/
    @Configuration
    public class WebConfig implements WebMvcConfigurer {
    
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
            registry.addResourceHandler("/pub/**")
                    .addResourceLocations("/static/", "classpath:/static/")
                    .setCacheControl(CacheControl.maxAge(7, TimeUnit.DAYS).cachePrivate())
                    .resourceChain(true)
                    .addResolver(new EncodedResourceResolver())
                    .addResolver(new VersionResourceResolver().addContentVersionStrategy("/**"));
        }
    
    }
    

      

  • 相关阅读:
    Spring学习(一)初识Spring
    搜索引擎学习(七)解析查询
    搜索引擎学习(六)Query的子类查询
    Oracle学习(十四)分表分区
    Oracle学习(十三)优化专题
    Python学习————流程控制之while循环
    Python学习————深浅copy
    Python学习————while循环作业
    Python学习————运算符
    Python学习————与用户交互
  • 原文地址:https://www.cnblogs.com/tangshengwei/p/13032025.html
Copyright © 2011-2022 走看看