## org.springframework.web.servlet.config.annotation
Class ResourceHandlerRegistration

    java.lang.Object
      org.springframework.web.servlet.config.annotation.ResourceHandlerRegistration

    public class ResourceHandlerRegistration

extends Object

Encapsulates information required to create a resource handlers.

Since:
  3.1
Author:
  Rossen Stoyanchev, Keith Donald

Constructor Summary
`ResourceHandlerRegistration(ResourceLoader resourceLoader, String... pathPatterns)` Create a `ResourceHandlerRegistration` instance.

Method Summary
`ResourceHandlerRegistration` `addResourceLocations(String... resourceLocations)` Add one or more resource locations from which to serve static content.
`protected String[]` `getPathPatterns()` Returns the URL path patterns for the resource handler.
`protected ResourceHttpRequestHandler` `getRequestHandler()` Returns a `ResourceHttpRequestHandler` instance.
`ResourceHandlerRegistration` `setCachePeriod(Integer cachePeriod)` Specify the cache period for the resources served by the resource handler, in seconds.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ResourceHandlerRegistration

    public ResourceHandlerRegistration(ResourceLoader resourceLoader,
                                       String... pathPatterns)

  Create a `ResourceHandlerRegistration` instance.

  Parameters:
    `resourceLoader` - a resource loader for turning a String location into a `Resource`
    `pathPatterns` - one or more resource URL path patterns

Method Detail

### addResourceLocations

    public ResourceHandlerRegistration addResourceLocations(String... resourceLocations)

  Add one or more resource locations from which to serve static content. Each location must point to a valid directory. Multiple locations may be specified as a comma-separated list, and the locations will be checked for a given resource in the order specified.

  For example, {`"/"`, `"classpath:/META-INF/public-web-resources/"`} allows resources to be served both from the web application root and from any JAR on the classpath that contains a `/META-INF/public-web-resources/` directory, with resources in the web application root taking precedence.

  Returns:
    the same `ResourceHandlerRegistration` instance for chained method invocation

### setCachePeriod

    public ResourceHandlerRegistration setCachePeriod(Integer cachePeriod)

  Specify the cache period for the resources served by the resource handler, in seconds. The default is to not send any cache headers but to rely on last-modified timestamps only. Set to 0 in order to send cache headers that prevent caching, or to a positive number of seconds to send cache headers with the given max-age value.

  Parameters:
    `cachePeriod` - the time to cache resources in seconds
  Returns:
    the same `ResourceHandlerRegistration` instance for chained method invocation

### getPathPatterns

    protected String[] getPathPatterns()

  Returns the URL path patterns for the resource handler.

### getRequestHandler

    protected ResourceHttpRequestHandler getRequestHandler()

  Returns a `ResourceHttpRequestHandler` instance.