类 DefaultServletHttpRequestHandler
- java.lang.Object
- org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler
- 所有已实现的接口:
Aware
,ServletContextAware
,HttpRequestHandler
public class DefaultServletHttpRequestHandler extends Object implements HttpRequestHandler, ServletContextAware
AnHttpRequestHandler
for serving static files using the Servlet container's "default" Servlet.This handler is intended to be used with a "/*" mapping when the
DispatcherServlet
is mapped to "/", thus overriding the Servlet container's default handling of static resources. The mapping to this handler should generally be ordered as the last in the chain so that it will only execute when no other more specific mappings (i.e., to controllers) can be matched.Requests are handled by forwarding through the
RequestDispatcher
obtained via the name specified through the"defaultServletName" property
. In most cases, thedefaultServletName
does not need to be set explicitly, as the handler checks at initialization time for the presence of the default Servlet of well-known containers such as Tomcat, Jetty, Resin, WebLogic and WebSphere. However, when running in a container where the default Servlet's name is not known, or where it has been customized via server configuration, thedefaultServletName
will need to be set explicitly.- 从以下版本开始:
- 3.0.4
- 作者:
- Jeremy Grelle, Juergen Hoeller
构造器概要
构造器 构造器 说明 DefaultServletHttpRequestHandler()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
handleRequest(HttpServletRequest request, HttpServletResponse response)
Process the given request, generating a response.void
setDefaultServletName(String defaultServletName)
Set the name of the default Servlet to be forwarded to for static resource requests.void
setServletContext(ServletContext servletContext)
If thedefaultServletName
property has not been explicitly set, attempts to locate the default Servlet using the known common container-specific names.
构造器详细资料
DefaultServletHttpRequestHandler
public DefaultServletHttpRequestHandler()
方法详细资料
setDefaultServletName
public void setDefaultServletName(String defaultServletName)
Set the name of the default Servlet to be forwarded to for static resource requests.
setServletContext
public void setServletContext(ServletContext servletContext)
If thedefaultServletName
property has not been explicitly set, attempts to locate the default Servlet using the known common container-specific names.- 指定者:
setServletContext
在接口中ServletContextAware
- 参数:
servletContext
- ServletContext object to be used by this object- 另请参阅:
InitializingBean.afterPropertiesSet()
,ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
handleRequest
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
从接口复制的说明:HttpRequestHandler
Process the given request, generating a response.- 指定者:
handleRequest
在接口中HttpRequestHandler
- 参数:
request
- current HTTP requestresponse
- current HTTP response- 抛出:
ServletException
- in case of general errorsIOException
- in case of I/O errors