类 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 MVCDispatcherServletis 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 aDefaultServletHandlerConfigurerinstance.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected SimpleUrlHandlerMappingbuildHandlerMapping()Return a handler mapping instance ordered atOrdered.LOWEST_PRECEDENCEcontaining theDefaultServletHttpRequestHandlerinstance mapped to"/**"; ornullif default servlet handling was not been enabled.voidenable()Enable forwarding to the "default" Servlet.voidenable(String defaultServletName)Enable forwarding to the "default" Servlet identified by the given name.
构造器详细资料
DefaultServletHandlerConfigurer
public DefaultServletHandlerConfigurer(ServletContext servletContext)
Create aDefaultServletHandlerConfigurerinstance.- 参数:
servletContext- the ServletContext to use.
方法详细资料
enable
public void enable()
Enable forwarding to the "default" Servlet.When this method is used the
DefaultServletHttpRequestHandlerwill try to autodetect the "default" Servlet name. Alternatively, you can specify the name of the default Servlet viaenable(String).
enable
public void enable(@Nullable 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
@Nullable protected SimpleUrlHandlerMapping buildHandlerMapping()
Return a handler mapping instance ordered atOrdered.LOWEST_PRECEDENCEcontaining theDefaultServletHttpRequestHandlerinstance mapped to"/**"; ornullif default servlet handling was not been enabled.- 从以下版本开始:
- 4.3.12