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.
DefaultServletHandlerConfigurer
| Modifier and Type | Field and Description |
|---|---|
| private final ApplicationContext | |
| private final ContentNegotiationManager | |
| private int | |
| private final UrlPathHelper | |
| private final List | |
| private final ServletContext |
| Access | Constructor and Description |
|---|---|
| public | ResourceHandlerRegistry(ApplicationContext
the Spring application context applicationContext, ServletContext the corresponding Servlet context servletContext)Create a new resource handler registry for the given application context. |
| public | ResourceHandlerRegistry(ApplicationContext
the Spring application context applicationContext, ServletContext the corresponding Servlet context servletContext, ContentNegotiationManager the content negotiation manager to use contentNegotiationManager)Create a new resource handler registry for the given application context. |
| public | ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext, ContentNegotiationManager contentNegotiationManager, UrlPathHelper pathHelper)
A variant of
|
| Modifier and Type | Method and Description |
|---|---|
| public ResourceHandlerRegistration | |
| protected AbstractHandlerMapping | getHandlerMapping()
Return a handler mapping with the mapped resource handlers; or |
| private ResourceHttpRequestHandler | |
| 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 |
| applicationContext | back to summary |
|---|---|
| private final ApplicationContext applicationContext | |
| contentNegotiationManager | back to summary |
|---|---|
| private final ContentNegotiationManager contentNegotiationManager
| |
| order | back to summary |
|---|---|
| private int order | |
| pathHelper | back to summary |
|---|---|
| private final UrlPathHelper pathHelper
| |
| registrations | back to summary |
|---|---|
| private final List<ResourceHandlerRegistration> registrations | |
| servletContext | back to summary |
|---|---|
| private final ServletContext servletContext | |
| ResourceHandlerRegistry | back to summary |
|---|---|
| public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext) Create a new resource handler registry for the given application context.
| |
| ResourceHandlerRegistry | back to summary |
|---|---|
| public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext, ContentNegotiationManager contentNegotiationManager) Create a new resource handler registry for the given application context.
| |
| ResourceHandlerRegistry | back to summary |
|---|---|
| public ResourceHandlerRegistry(ApplicationContext applicationContext, ServletContext servletContext, ContentNegotiationManager contentNegotiationManager, UrlPathHelper pathHelper) A variant of
| |
| addResourceHandler | back to summary |
|---|---|
| public ResourceHandlerRegistration addResourceHandler(String... pathPatterns) Add a resource handler to serve static resources. The handler is invoked for requests that match one of the specified URL path patterns. Patterns such as For pattern syntax see | |
| getHandlerMapping | back to summary |
|---|---|
| protected AbstractHandlerMapping getHandlerMapping() Return a handler mapping with the mapped resource handlers; or
| |
| getRequestHandler | back to summary |
|---|---|
private ResourceHttpRequestHandler 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 | |