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

      

  • 相关阅读:
    HDU2013 蟠桃记
    HDU2012 素数判定
    I00030 Grades conversion
    HDU2011 多项式求和
    HDU2009 求数列的和
    HDU2005 第几天?【日期计算】
    HDU2004 成绩转换
    HDU2006 求奇数的乘积
    HDU2007 平方和与立方和【序列处理】
    HDU2010 水仙花数【进制+趣味程序】
  • 原文地址:https://www.cnblogs.com/tangshengwei/p/13032025.html
Copyright © 2011-2022 走看看