类 DefaultServletHttpRequestHandler

java.lang.Object
cn.taketoday.web.resource.DefaultServletHttpRequestHandler
所有已实现的接口:
cn.taketoday.beans.factory.Aware, HttpRequestHandler, ServletContextAware

public class DefaultServletHttpRequestHandler extends Object implements HttpRequestHandler, ServletContextAware
An HttpRequestHandler 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, the defaultServletName 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, the defaultServletName will need to be set explicitly.

从以下版本开始:
4.0
作者:
Jeremy Grelle, Juergen Hoeller, Harry Yang
  • 字段详细资料

    • COMMON_DEFAULT_SERVLET_NAME

      private static final String COMMON_DEFAULT_SERVLET_NAME
      Default Servlet name used by Tomcat, Jetty, JBoss, and GlassFish.
      另请参阅:
    • GAE_DEFAULT_SERVLET_NAME

      private static final String GAE_DEFAULT_SERVLET_NAME
      Default Servlet name used by Google App Engine.
      另请参阅:
    • RESIN_DEFAULT_SERVLET_NAME

      private static final String RESIN_DEFAULT_SERVLET_NAME
      Default Servlet name used by Resin.
      另请参阅:
    • WEBLOGIC_DEFAULT_SERVLET_NAME

      private static final String WEBLOGIC_DEFAULT_SERVLET_NAME
      Default Servlet name used by WebLogic.
      另请参阅:
    • WEBSPHERE_DEFAULT_SERVLET_NAME

      private static final String WEBSPHERE_DEFAULT_SERVLET_NAME
      Default Servlet name used by WebSphere.
      另请参阅:
    • defaultServletName

      @Nullable private String defaultServletName
    • servletContext

      @Nullable private ServletContext servletContext
  • 构造器详细资料

    • DefaultServletHttpRequestHandler

      public DefaultServletHttpRequestHandler()
  • 方法详细资料

    • setDefaultServletName

      public void setDefaultServletName(@Nullable String defaultServletName)
      Set the name of the default Servlet to be forwarded to for static resource requests.
    • setServletContext

      public void setServletContext(ServletContext servletContext)
      If the defaultServletName property has not been explicitly set, attempts to locate the default Servlet using the known common container-specific names.
      指定者:
      setServletContext 在接口中 ServletContextAware
      参数:
      servletContext - the ServletContext object to be used by this object
      另请参阅:
      • InitializingBean.afterPropertiesSet()
      • ApplicationContextAware.setApplicationContext(cn.taketoday.context.ApplicationContext)
    • handleRequest

      public Object handleRequest(RequestContext request) throws Throwable
      从接口复制的说明: HttpRequestHandler
      Process the request and return a result object which the DispatcherHandler will handle. A null return value is not an error: it indicates that this handler completed request processing itself and that there is therefore no explicit result to handle. a HttpRequestHandler.NONE_RETURN_VALUE indicates that no result to handle by ReturnValueHandler
      指定者:
      handleRequest 在接口中 HttpRequestHandler
      参数:
      request - Current request context
      返回:
      Result to be handled by ReturnValueHandler
      抛出:
      Throwable - If any exception occurred
      另请参阅: