zoukankan      html  css  js  c++  java
  • sp资源处理的默认规则

    资源处理的默认规则

    @Override
    		public void addResourceHandlers(ResourceHandlerRegistry registry) {
    			if (!this.resourceProperties.isAddMappings()) {
    				logger.debug("Default resource handling disabled");
    				return;
    			}
    			Duration cachePeriod = this.resourceProperties.getCache().getPeriod();
    			CacheControl cacheControl = this.resourceProperties.getCache().getCachecontrol().toHttpCacheControl();
    			//webjars的规则
                if (!registry.hasMappingForPattern("/webjars/**")) {
    				customizeResourceHandlerRegistration(registry.addResourceHandler("/webjars/**")
    						.addResourceLocations("classpath:/META-INF/resources/webjars/")
    						.setCachePeriod(getSeconds(cachePeriod)).setCacheControl(cacheControl));
    			}
                
                //
    			String staticPathPattern = this.mvcProperties.getStaticPathPattern();
    			if (!registry.hasMappingForPattern(staticPathPattern)) {
    				customizeResourceHandlerRegistration(registry.addResourceHandler(staticPathPattern)
    						.addResourceLocations(getResourceLocations(this.resourceProperties.getStaticLocations()))
    						.setCachePeriod(getSeconds(cachePeriod)).setCacheControl(cacheControl));
    			}
    		}
    
    spring:
    #  mvc:
    #    static-path-pattern: /res/**
    
      resources:
        add-mappings: false   禁用所有静态资源规则
    @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;
    
  • 相关阅读:
    简单地通过Python库使用python的socket编程
    js 实现继承的几种方式
    JAVA中获取当前系统时间
    IntelliJ Idea 常用快捷键列表
    关于报错:There is already 'xxxController' bean method的解决方法
    mysql 使用 GROUP BY 时报错 ERROR 1055 (42000)
    安装系统,用cmd进行分区
    Bootstrap关闭当前页
    bootstrap的日期选择器
    Bootstrap如何关闭弹窗
  • 原文地址:https://www.cnblogs.com/zhukaile/p/15570064.html
Copyright © 2011-2022 走看看