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("/**"));
        }
    
    }
    

      

  • 相关阅读:
    项目打包文件build.xml
    【转】常见面试之机器学习算法思想简单梳理
    【转】11位机器学习大牛最爱算法全解
    Simplify Path
    Text Justification
    Valid Number
    Substring with Concatenation of All Words
    Shortest Palindrome
    Palindrome Pairs
    Decode Ways
  • 原文地址:https://www.cnblogs.com/tangshengwei/p/13032025.html
Copyright © 2011-2022 走看看