public final class

MvcResources

extends AbstractFeatureSpecification
java.lang.Object
   ↳ org.springframework.context.config.AbstractFeatureSpecification
     ↳ org.springframework.web.servlet.config.MvcResources

Class Overview

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

Summary

[Expand]
Inherited Fields
From class org.springframework.context.config.AbstractFeatureSpecification
Public Constructors
MvcResources(String mapping, String... locations)
Create an MvcResources specification instance.
MvcResources(String mapping, Resource... resources)
Create an MvcResources specification instance.
Public Methods
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.
MvcResources order(String order)
Specify an order as a String.
MvcResources order(Integer order)
Specify a cachePeriod as a String.
Protected Methods
void doValidate(ProblemCollector problems)
[Expand]
Inherited Methods
From class org.springframework.context.config.AbstractFeatureSpecification
From class java.lang.Object
From interface org.springframework.context.config.FeatureSpecification
From interface org.springframework.context.config.SourceAwareSpecification

Public Constructors

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.

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.

Public Methods

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

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

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 LOWEST_PRECEDENCE - 1.

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 LOWEST_PRECEDENCE - 1.

Protected Methods

protected void doValidate (ProblemCollector problems)