org.springframework.web.servlet.config
Class MvcResources

java.lang.Object
  extended by org.springframework.context.config.AbstractFeatureSpecification
      extended by org.springframework.web.servlet.config.MvcResources
All Implemented Interfaces:
FeatureSpecification, SourceAwareSpecification

public final class MvcResources
extends AbstractFeatureSpecification

Specifies the Spring MVC "resources" container feature. The feature provides the following fine-grained configuration:

Since:
3.1
Author:
Rossen Stoynchev

Field Summary
 
Fields inherited from class org.springframework.context.config.AbstractFeatureSpecification
executorType
 
Constructor Summary
MvcResources(String mapping, Resource... resources)
          Create an MvcResources specification instance.
MvcResources(String mapping, String... locations)
          Create an MvcResources specification instance.
 
Method Summary
 MvcResources cachePeriod(Integer cachePeriod)
          The period of time resources should be cached for in seconds.
 MvcResources cachePeriod(String cachePeriod)
          Specify a cachePeriod as a String.
protected  void doValidate(ProblemCollector problems)
           
 MvcResources order(Integer order)
          Specify a cachePeriod as a String.
 MvcResources order(String order)
          Specify an order as a String.
 
Methods inherited from class org.springframework.context.config.AbstractFeatureSpecification
execute, source, source, sourceName, sourceName, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MvcResources

public MvcResources(String mapping,
                    String... locations)
Create an MvcResources specification instance. See alternate constructor you prefer to use Resource instances instead of String-based resource locations.

Parameters:
mapping - - the URL path pattern within the current Servlet context to use to identify resource requests (e.g. "/resources/**").
locations - - locations of resources containing static content to be served. Each location must point to a valid directory. Locations will be checked in the order specified. For example if "/" and "classpath:/META-INF/public-web-resources/" are configured resources will be served from the Web root and from any JAR on the classpath that contains a /META-INF/public-web-resources/ directory, with resources under the Web root taking precedence.

MvcResources

public MvcResources(String mapping,
                    Resource... resources)
Create an MvcResources specification instance. See alternate constructor defined here if you prefer to use String-based path patterns.

Parameters:
mapping - - the URL path pattern within the current Servlet context to use to identify resource requests (e.g. "/resources/**").
resources - - Spring Resource objects containing static content to be served. Resources will be checked in the order specified.
Method Detail

cachePeriod

public MvcResources cachePeriod(Integer cachePeriod)
The period of time resources should be cached for in seconds. The default is to not send any cache headers but rather to rely on last-modified timestamps only.

Set this to 0 in order to send cache headers that prevent caching, or to a positive number of seconds in order to send cache headers with the given max-age value.

Parameters:
cachePeriod - the cache period in seconds

cachePeriod

public MvcResources cachePeriod(String cachePeriod)
Specify a cachePeriod as a String. An alternative to cachePeriod(Integer). The String must represent an Integer after placeholder and SpEL expression resolution.

Parameters:
cachePeriod - the cache period in seconds

order

public MvcResources order(Integer order)
Specify a cachePeriod as a String. An alternative to cachePeriod(Integer). The String must represent an Integer after placeholder and SpEL expression resolution.

Sets the order for the SimpleUrlHandlerMapping used to match resource requests relative to order value for other HandlerMapping instances such as the DefaultAnnotationHandlerMapping used to match controller requests.

Parameters:
order - the order to use. The default value is Ordered.LOWEST_PRECEDENCE - 1.

order

public MvcResources order(String order)
Specify an order as a String. An alternative to order(Integer). The String must represent an Integer after placeholder and SpEL expression resolution.

Parameters:
order - the order to use. The default value is Ordered.LOWEST_PRECEDENCE - 1.

doValidate

protected void doValidate(ProblemCollector problems)
Specified by:
doValidate in class AbstractFeatureSpecification