• 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;
    
  • 相关阅读:
    css中的选择器
    HTML5总结
    table中的一些另类标签
    form表单
    Laravel常用命令行中文版
    浅谈Session与Cookie的区别与联系
    Wechat微信公众平台开发
    js中的正则表达式入门
    畅谈Redis和Memcached的区别
    php的ob缓存详解
  • 原文地址:https://www.cnblogs.com/zhukaile/p/15570064.html
Copyright © 2020-2023  润新知