类 ResourceHandlerRegistry
java.lang.Object
cn.taketoday.web.config.ResourceHandlerRegistry
Stores registrations of resource handlers for serving static resources such
as images, css files and others through Web MVC including setting cache
headers optimized for efficient loading in a web browser. Resources can be
served out of locations under web application root, from the classpath, and
others.
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.
- 从以下版本开始:
- 4.0 2022/2/15 17:07
- 作者:
- Rossen Stoyanchev, Harry Yang
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明private final cn.taketoday.context.ApplicationContextprivate final ContentNegotiationManagerprivate HttpRequestHandlerprivate intprivate final List<ResourceHandlerRegistration> -
构造器概要
构造器构造器说明ResourceHandlerRegistry(cn.taketoday.context.ApplicationContext context) Create a new resource handler registry for the given application context.ResourceHandlerRegistry(cn.taketoday.context.ApplicationContext context, ContentNegotiationManager contentNegotiationManager) Create a new resource handler registry for the given application context. -
方法概要
修饰符和类型方法说明addResourceHandler(String... pathPatterns) Add a resource handler to serve static resources.protected SimpleUrlHandlerMappingReturn a handler mapping with the mapped resource handlers; ornullin case of no registrations.private ResourceHttpRequestHandlergetRequestHandler(ResourceHandlerRegistration registration) booleanhasMappingForPattern(String pathPattern) Whether a resource handler has already been registered for the given path pattern.voidsetNotFoundHandler(HttpRequestHandler notFoundHandler) Set not found handlervoidsetOrder(int order) Specify the order to use for resource handling relative to otherHandlerRegistriesconfigured in the MVC application context.
-
字段详细资料
-
applicationContext
private final cn.taketoday.context.ApplicationContext applicationContext -
contentNegotiationManager
-
registrations
-
order
private int order -
notFoundHandler
-
-
构造器详细资料
-
ResourceHandlerRegistry
public ResourceHandlerRegistry(cn.taketoday.context.ApplicationContext context) Create a new resource handler registry for the given application context.- 参数:
context- the application context
-
ResourceHandlerRegistry
public ResourceHandlerRegistry(cn.taketoday.context.ApplicationContext context, @Nullable ContentNegotiationManager contentNegotiationManager) Create a new resource handler registry for the given application context.- 参数:
context- the application contextcontentNegotiationManager- the content negotiation manager to use
-
-
方法详细资料
-
addResourceHandler
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
"/static/**"or"/css/{filename:\\w+\\.css}"are supported. -
hasMappingForPattern
Whether a resource handler has already been registered for the given path pattern. -
setOrder
public void setOrder(int order) Specify the order to use for resource handling relative to otherHandlerRegistriesconfigured in the MVC application context.The default value used is
Integer.MAX_VALUE-1. -
setNotFoundHandler
Set not found handlerhandle resource not found
- 参数:
notFoundHandler- HttpRequestHandler
-
getHandlerMapping
Return a handler mapping with the mapped resource handlers; ornullin case of no registrations. -
getRequestHandler
-