org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry Java Examples

The following examples show how to use org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #2
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #3
Source File: StaticResourceConfiguration.java    From testing_platform with Apache License 2.0 6 votes vote down vote up
@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // TODO: wangc@2017/3/15  这里可能需要根据OS不同配置不同的路径,win:file后有3个/,linux:file后有2个/,因为linux的目录本身就是/开头 


        String separator = "/";
        if( os.contains("Linux") ){//如果是linux    // TODO: wangc@2017/3/15  app_init 中判断OS 
            separator = "";
        }
        //win:   file:///c:dir_name
        //linux:  file:///home/wangc/dir_name
//        String reportResLocations = FILE_PREX+separator+ Param.USER_DIR+Param.HTML_PATH;
        //将所有的/report/请求至html报告的本地路径
//        registry.addResourceHandler("/report/**").addResourceLocations(reportResLocations);

        String reportResLocations = FILE_PREX+separator+ Param.USER_DIR+Param.HTML_PATH+File.separator;
        
//        reportResLocations = "file:///D:/workspace_HelloWorld/testing_platform/jmeter/html/";
        registry.addResourceHandler("/report/**").addResourceLocations(reportResLocations);
                              //file:///D:/workspace_HelloWorld/testing_platform/jmeter/html
        super.addResourceHandlers(registry);
    }
 
Example #4
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #5
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #6
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #7
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #8
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
            .setCachePeriod(0)//Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #9
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #10
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #11
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #12
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #13
Source File: WebMvcConfig.java    From Spring-Security-Third-Edition with MIT License 6 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**")
            .addResourceLocations("/resources/")
            .setCachePeriod(0) //Set to 0 in order to send cache headers that prevent caching
            .setCachePeriod(0)//Set to 0 in order to send cache headers that prevent caching
    ;

    // Add WebJars for Bootstrap & jQuery
    if (!registry.hasMappingForPattern("/webjars/**")) {
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/").resourceChain(true);
    }

    if (!registry.hasMappingForPattern("/**")) {
        registry.addResourceHandler("/**").addResourceLocations(
                CLASSPATH_RESOURCE_LOCATIONS);

    }
}
 
Example #14
Source File: WebMVCConfig.java    From hygieia-core with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    String[] staticResourceMappingPath = {"classpath:/static/"};

    registry.addResourceHandler("/**").addResourceLocations(
            staticResourceMappingPath);
}
 
Example #15
Source File: CacheWebConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/resources/**").addResourceLocations("/resources/")
      .setCacheControl(CacheControl.maxAge(60, TimeUnit.SECONDS)
        .noTransform()
        .mustRevalidate());
}
 
Example #16
Source File: WebConfig.java    From SkaETL with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #17
Source File: WebConfig.java    From Spring with Apache License 2.0 5 votes vote down vote up
/** Internationalisation End */

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		registry.addResourceHandler("/pdf/**").addResourceLocations("/WEB-INF/pdf/");
		registry.addResourceHandler("/css/**").addResourceLocations("/WEB-INF/css/");
	}
 
Example #18
Source File: WebConfig.java    From taoshop with Apache License 2.0 5 votes vote down vote up
@Override  
public void addResourceHandlers(ResourceHandlerRegistry registry) {
  
    registry.addResourceHandler("/templates/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/templates/");
    registry.addResourceHandler("/static/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/static/");
    registry.addResourceHandler("/plugins/**").addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+"/static/");
    super.addResourceHandlers(registry);
}
 
Example #19
Source File: CorsConfig.java    From parker with MIT License 5 votes vote down vote up
/**
 * 跨域配置后swagger2可能不能访问,需要增加如下配置
 * @param registry
 */
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");

}
 
Example #20
Source File: Application.java    From chatbot with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/assets/**").addResourceLocations("file:node_modules/").setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
    registry.addResourceHandler("/js/**").addResourceLocations("file:src/main/app/js/").setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
    registry.addResourceHandler("/css/**").addResourceLocations("file:src/main/app/css/").setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
    registry.addResourceHandler("/images/**").addResourceLocations("file:src/main/resources/static/images/").setCacheControl(CacheControl.maxAge(1, TimeUnit.DAYS));
    super.addResourceHandlers(registry);
}
 
Example #21
Source File: ResourcesConfig.java    From RuoYi with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    // 文件上传路径
    registry.addResourceHandler("/profile/**").addResourceLocations("file:" + Global.getProfile());

    // swagger配置
    registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #22
Source File: WebMvcConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
    registry.addResourceHandler(fileConfig.getFileVirtualPath()).addResourceLocations("file:"+ fileConfig.getFileActualPath());
    super.addResourceHandlers(registry);
}
 
Example #23
Source File: MvcConfigurationPrivate.java    From oncokb with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/swagger-ui.html")
        .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
        .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #24
Source File: SwaggerConfig.java    From kardio with Apache License 2.0 5 votes vote down vote up
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
 
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #25
Source File: ResourcesConfig.java    From RuoYi-Vue with MIT License 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry)
{
    /** 本地文件上传路径 */
    registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**").addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");

    /** swagger配置 */
    registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #26
Source File: WebConfig.java    From wetech-admin with MIT License 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    registry.addResourceHandler("/**").addResourceLocations(
            "classpath:/META-INF/resources/webjars/wetech-admin-ui/");
}
 
Example #27
Source File: KitchenSinkWebMvcConfigurer.java    From line-bot-sdk-java with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

    String downloadedContentUri = KitchenSinkApplication.downloadedContentDir
            .toUri().toASCIIString();
    log.info("downloaded dir: {}", downloadedContentUri);
    registry.addResourceHandler("/downloaded/**")
            .addResourceLocations(downloadedContentUri);
    registry.addResourceHandler("/static/**")
            .addResourceLocations("classpath:/static/");
}
 
Example #28
Source File: StaticWebMvcConfiguration.java    From Moss with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {

    registry.addResourceHandler("/**")
            .addResourceLocations("classpath:/META-INF/resources/", "classpath:/static/");


    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
 
Example #29
Source File: MvcConfig.java    From skywalking with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(final ResourceHandlerRegistry registry) {
    registry.addResourceHandler("/index.html").addResourceLocations("classpath:/public/index.html");
    registry.addResourceHandler("/css/**").addResourceLocations("classpath:/public/css/");
    registry.addResourceHandler("/img/**").addResourceLocations("classpath:/public/img/");
    registry.addResourceHandler("/js/**").addResourceLocations("classpath:/public/js/");
    registry.addResourceHandler("/favicon.ico").addResourceLocations("classpath:/public/favicon.ico");
    registry.addResourceHandler("/logo.png").addResourceLocations("classpath:/public/logo.png");
}
 
Example #30
Source File: ResourceConfig.java    From swagger-more with Apache License 2.0 5 votes vote down vote up
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry
            .addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry
            .addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
    registry
            .addResourceHandler("/api/**")
            .addResourceLocations("classpath:/META-INF/resources/static/");
}