To create a resource handler, use addResourceHandler(String.
providing the URL path patterns for which the handler should be invoked to
serve static resources (e.g. "/resources/**").
Then use additional methods on the returned
ResourceHandlerRegistration to add one or more locations from which
to serve static content from (e.g. {"/",
"classpath:/META-INF/public-web-resources/"}) or to specify a cache
period for served resources.
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final List | |
| private final ResourceLoader | |
| private ResourceUrlProvider |
| Access | Constructor and Description |
|---|---|
| public | ResourceHandlerRegistry(ResourceLoader
the resource loader to use resourceLoader)Create a new resource handler registry for the given resource loader (typically an application context). |
| Modifier and Type | Method and Description |
|---|---|
| public ResourceHandlerRegistration | Returns: aResourceHandlerRegistration to use to further configure
the registered resource handlerAdd a resource handler for serving static resources based on the specified URL path patterns. |
| protected AbstractUrlHandlerMapping | getHandlerMapping()
Return a handler mapping with the mapped resource handlers; or |
| private ResourceWebHandler | |
| public boolean | hasMappingForPattern(String pathPattern)
Whether a resource handler has already been registered for the given path pattern. |
| public ResourceHandlerRegistry | setOrder(int order)
Specify the order to use for resource handling relative to other
|
| public void | setResourceUrlProvider(ResourceUrlProvider
the resource URL provider to use resourceUrlProvider)Configure the |
| order | back to summary |
|---|---|
| private int order | |
| registrations | back to summary |
|---|---|
| private final List<ResourceHandlerRegistration> registrations | |
| resourceLoader | back to summary |
|---|---|
| private final ResourceLoader resourceLoader | |
| resourceUrlProvider | back to summary |
|---|---|
| private ResourceUrlProvider resourceUrlProvider
| |
| ResourceHandlerRegistry | back to summary |
|---|---|
| public ResourceHandlerRegistry(ResourceLoader resourceLoader) Create a new resource handler registry for the given resource loader (typically an application context).
| |
| addResourceHandler | back to summary |
|---|---|
| public ResourceHandlerRegistration addResourceHandler(String... patterns) Add a resource handler for serving static resources based on the specified URL path patterns. The handler will be invoked for every incoming request that matches to one of the specified path patterns. Patterns like
| |
| getHandlerMapping | back to summary |
|---|---|
| protected AbstractUrlHandlerMapping getHandlerMapping() Return a handler mapping with the mapped resource handlers; or
| |
| getRequestHandler | back to summary |
|---|---|
| private ResourceWebHandler getRequestHandler(ResourceHandlerRegistration registration) | |
| hasMappingForPattern | back to summary |
|---|---|
| public boolean hasMappingForPattern(String pathPattern) Whether a resource handler has already been registered for the given path pattern. | |
| setOrder | back to summary |
|---|---|
| public ResourceHandlerRegistry setOrder(int order) Specify the order to use for resource handling relative to other
The default value used is | |
| setResourceUrlProvider | back to summary |
|---|---|
| public void setResourceUrlProvider(ResourceUrlProvider resourceUrlProvider) Configure the
| |