类 DispatcherServlet

所有已实现的接口:
cn.taketoday.beans.factory.Aware, cn.taketoday.beans.factory.BeanNameAware, cn.taketoday.context.ApplicationContextAware, cn.taketoday.context.EnvironmentAware, cn.taketoday.core.env.EnvironmentCapable, Servlet, Serializable

public class DispatcherServlet extends DispatcherHandler implements Servlet, Serializable
Central dispatcher for HTTP request handlers/controllers in Servlet
从以下版本开始:
2.0
作者:
TODAY 2018-06-25 19:47:14
另请参阅:
  • 字段详细资料

    • serialVersionUID

      private static final long serialVersionUID
      另请参阅:
    • SERVLET_CONTEXT_PREFIX

      public static final String SERVLET_CONTEXT_PREFIX
      Prefix for the ServletContext attribute for the ApplicationContext. The completion is the servlet name.
    • servletConfig

      private transient ServletConfig servletConfig
    • contextAttribute

      @Nullable private String contextAttribute
      ServletContext attribute to find the WebApplicationContext in.
    • publishContext

      private boolean publishContext
      Should we publish the context as a ServletContext attribute?.
  • 构造器详细资料

  • 方法详细资料

    • setContextAttribute

      public void setContextAttribute(@Nullable String contextAttribute)
      Set the name of the ServletContext attribute which should be used to retrieve the WebApplicationContext that this servlet is supposed to use.
      从以下版本开始:
      4.0
    • getContextAttribute

      @Nullable public String getContextAttribute()
      Return the name of the ServletContext attribute which should be used to retrieve the WebApplicationContext that this servlet is supposed to use.
      从以下版本开始:
      4.0
    • setPublishContext

      public void setPublishContext(boolean publishContext)
      Set whether to publish this servlet's context as a ServletContext attribute, available to all objects in the web container. Default is "true".

      This is especially handy during testing, although it is debatable whether it's good practice to let other application objects access the context this way.

      从以下版本开始:
      4.0
    • createEnvironment

      protected cn.taketoday.core.env.ConfigurableEnvironment createEnvironment()
      从类复制的说明: InfraHandler
      Create and return a new StandardEnvironment.

      Subclasses may override this in order to configure the environment or specialize the environment type returned.

      覆盖:
      createEnvironment 在类中 InfraHandler
    • init

      public void init(ServletConfig servletConfig)
      指定者:
      init 在接口中 Servlet
    • afterApplicationContextInit

      protected void afterApplicationContextInit()
      从类复制的说明: InfraHandler
      This method will be invoked after any bean properties have been set and the ApplicationContext has been loaded. The default implementation is empty; subclasses may override this method to perform any initialization they require.
      覆盖:
      afterApplicationContextInit 在类中 InfraHandler
    • applyInitializers

      protected void applyInitializers(cn.taketoday.context.ConfigurableApplicationContext context, List<cn.taketoday.context.ApplicationContextInitializer> initializers)
      从类复制的说明: InfraHandler
      Delegate the ApplicationContext before it is refreshed to any ApplicationContextInitializer instances specified by the "contextInitializerClasses" servlet init-param.

      See also InfraHandler.postProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext), which is designed to allow subclasses (as opposed to end-users) to modify the application context, and is called immediately before this method.

      覆盖:
      applyInitializers 在类中 InfraHandler
      参数:
      context - the configured ApplicationContext (not refreshed yet)
      initializers - ApplicationContextInitializer list
      另请参阅:
    • postProcessApplicationContext

      protected void postProcessApplicationContext(cn.taketoday.context.ConfigurableApplicationContext context)
      从类复制的说明: InfraHandler
      Post-process the given ApplicationContext before it is refreshed and activated as context for this handler.

      The default implementation is empty. refresh() will be called automatically after this method returns.

      Note that this method is designed to allow subclasses to modify the application context, while InfraHandler.initApplicationContext() is designed to allow end-users to modify the context through the use of ApplicationContextInitializers.

      覆盖:
      postProcessApplicationContext 在类中 InfraHandler
      参数:
      context - the configured ApplicationContext (not refreshed yet)
      另请参阅:
    • applyDefaultContextId

      protected void applyDefaultContextId(cn.taketoday.context.ConfigurableApplicationContext context)
      覆盖:
      applyDefaultContextId 在类中 InfraHandler
    • getRootApplicationContext

      protected cn.taketoday.context.ApplicationContext getRootApplicationContext()
      覆盖:
      getRootApplicationContext 在类中 InfraHandler
    • getServletContext

      public ServletContext getServletContext()
      Returns a reference to the ServletContext in which this servlet is running. See ServletConfig.getServletContext().

      This method is supplied for convenience. It gets the context from the servlet's ServletConfig object.

      返回:
      ServletContext the ServletContext object passed to this servlet by the init method
    • findApplicationContext

      @Nullable protected cn.taketoday.context.ApplicationContext findApplicationContext()
      Retrieve a ApplicationContext from the ServletContext attribute with the configured name. The ApplicationContext must have already been loaded and stored in the ServletContext before this servlet gets initialized (or invoked).

      Subclasses may override this method to provide a different ApplicationContext retrieval strategy.

      覆盖:
      findApplicationContext 在类中 InfraHandler
      返回:
      the ApplicationContext for this servlet, or null if not found
      另请参阅:
    • getServletContextAttributeName

      public String getServletContextAttributeName()
      Return the ServletContext attribute name for this servlet's WebApplicationContext.

      The default implementation returns SERVLET_CONTEXT_PREFIX + servlet name.

      另请参阅:
    • service

      public void service(ServletRequest request, ServletResponse response) throws ServletException
      指定者:
      service 在接口中 Servlet
      抛出:
      ServletException
    • getServletConfig

      public ServletConfig getServletConfig()
      指定者:
      getServletConfig 在接口中 Servlet
    • getServletInfo

      public final String getServletInfo()
      指定者:
      getServletInfo 在接口中 Servlet
    • getServletName

      public String getServletName()
      Returns the name of this servlet instance. See ServletConfig.getServletName().
      返回:
      the name of this servlet instance
    • logInfo

      protected void logInfo(String msg)
      从类复制的说明: InfraHandler
      Log internal
      覆盖:
      logInfo 在类中 InfraHandler
      参数:
      msg - Log message