类 DefaultServletHandlerConfigurer
- java.lang.Object
- org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer
public class DefaultServletHandlerConfigurer extends Object
Configures a request handler for serving static resources by forwarding the request to the Servlet container's "default" Servlet. This is intended to be used when the Spring MVCDispatcherServlet
is mapped to "/" thus overriding the Servlet container's default handling of static resources.Since this handler is configured at the lowest precedence, effectively it allows all other handler mappings to handle the request, and if none of them do, this handler can forward it to the "default" Servlet.
- 从以下版本开始:
- 3.1
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
- 另请参阅:
DefaultServletHttpRequestHandler
构造器概要
构造器 构造器 说明 DefaultServletHandlerConfigurer(ServletContext servletContext)
Create aDefaultServletHandlerConfigurer
instance.
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 protected SimpleUrlHandlerMapping
buildHandlerMapping()
Return a handler mapping instance ordered atInteger.MAX_VALUE
containing theDefaultServletHttpRequestHandler
instance mapped to"/**"
; ornull
if default servlet handling was not been enabled.void
enable()
Enable forwarding to the "default" Servlet.void
enable(String defaultServletName)
Enable forwarding to the "default" Servlet identified by the given name.protected AbstractHandlerMapping
getHandlerMapping()
已过时。as of 4.3.12, in favor ofbuildHandlerMapping()
构造器详细资料
DefaultServletHandlerConfigurer
public DefaultServletHandlerConfigurer(ServletContext servletContext)
Create aDefaultServletHandlerConfigurer
instance.- 参数:
servletContext
- the ServletContext to use.
方法详细资料
enable
public void enable()
Enable forwarding to the "default" Servlet.When this method is used the
DefaultServletHttpRequestHandler
will try to autodetect the "default" Servlet name. Alternatively, you can specify the name of the default Servlet viaenable(String)
.
enable
public void enable(String defaultServletName)
Enable forwarding to the "default" Servlet identified by the given name.This is useful when the default Servlet cannot be autodetected, for example when it has been manually configured.
buildHandlerMapping
protected SimpleUrlHandlerMapping buildHandlerMapping()
Return a handler mapping instance ordered atInteger.MAX_VALUE
containing theDefaultServletHttpRequestHandler
instance mapped to"/**"
; ornull
if default servlet handling was not been enabled.- 从以下版本开始:
- 4.3.12
getHandlerMapping
@Deprecated protected AbstractHandlerMapping getHandlerMapping()
已过时。as of 4.3.12, in favor ofbuildHandlerMapping()