您的位置:首页 > 编程语言 > Java开发

共同学习SpringMVC源码--DispatcherServlet(一)

2016-05-31 22:54 337 查看
public class DispatcherServlet extends FrameworkServlet

这是类签名,继承自FrameworkServlet。我会抽出篇幅来介绍这个父类。

/** Well-known name for the MultipartResolver object in the bean factory for this namespace. */

public static final String MULTIPART_RESOLVER_BEAN_NAME = "multipartResolver";

/** Well-known name for the LocaleResolver object in the bean factory for this namespace. */

public static final String LOCALE_RESOLVER_BEAN_NAME = "localeResolver";

/** Well-known name for the ThemeResolver object in the bean factory for this namespace. */

public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver";
/**
* Well-known name for the HandlerMapping object in the bean factory for this namespace.
* Only used when "detectAllHandlerMappings" is turned off.
* @see #setDetectAllHandlerMappings
*/

public static final String HANDLER_MAPPING_BEAN_NAME = "handlerMapping";
/**
* Well-known name for the HandlerAdapter object in the bean factory for this namespace.
* Only used when "detectAllHandlerAdapters" is turned off.
* @see #setDetectAllHandlerAdapters
*/

public static final String HANDLER_ADAPTER_BEAN_NAME = "handlerAdapter";
/**
* Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace.
* Only used when "detectAllHandlerExceptionResolvers" is turned off.
* @see #setDetectAllHandlerExceptionResolvers
*/

public static final String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME = "handlerExceptionResolver";
/**
* Well-known name for the RequestToViewNameTranslator object in the bean factory for this namespace.
*/

public static final String REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME = "viewNameTranslator";
/**
* Well-known name for the ViewResolver object in the bean factory for this namespace.
* Only used when "detectAllViewResolvers" is turned off.
* @see #setDetectAllViewResolvers
*/

public static final String VIEW_RESOLVER_BEAN_NAME = "viewResolver";
/**
* Well-known name for the FlashMapManager object in the bean factory for this namespace.
*/

public static final String FLASH_MAP_MANAGER_BEAN_NAME = "flashMapManager";

以上这些静态final的字符串成员变量都是各种bean的名称。
/**
* Request attribute to hold the current web application context.
* Otherwise only the global web app context is obtainable by tags etc.
* @see org.springframework.web.servlet.support.RequestContextUtils#findWebApplicationContext
*/

public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE = DispatcherServlet.class.getName() + ".CONTEXT";
/**
* Request attribute to hold the current LocaleResolver, retrievable by views.
* @see org.springframework.web.servlet.support.RequestContextUtils#getLocaleResolver
*/

public static final String LOCALE_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".LOCALE_RESOLVER";
/**
* Request attribute to hold the current ThemeResolver, retrievable by views.
* @see org.springframework.web.servlet.support.RequestContextUtils#getThemeResolver
*/

public static final String THEME_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_RESOLVER";
/**
* Request attribute to hold the current ThemeSource, retrievable by views.
* @see org.springframework.web.servlet.support.RequestContextUtils#getThemeSource
*/

public static final String THEME_SOURCE_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_SOURCE";
/**
* Name of request attribute that holds a read-only {@code Map<String,?>}
* with "input" flash attributes saved by a previous request, if any.
* @see org.springframework.web.servlet.support.RequestContextUtils#getInputFlashMap(HttpServletRequest)
*/

public static final String INPUT_FLASH_MAP_ATTRIBUTE = DispatcherServlet.class.getName() + ".INPUT_FLASH_MAP";
/**
* Name of request attribute that holds the "output" {@link FlashMap} with
* attributes to save for a subsequent request.
* @see org.springframework.web.servlet.support.RequestContextUtils#getOutputFlashMap(HttpServletRequest)
*/

public static final String OUTPUT_FLASH_MAP_ATTRIBUTE = DispatcherServlet.class.getName() + ".OUTPUT_FLASH_MAP";
/**
* Name of request attribute that holds the {@link FlashMapManager}.
* @see org.springframework.web.servlet.support.RequestContextUtils#getFlashMapManager(HttpServletRequest)
*/

public static final String FLASH_MAP_MANAGER_ATTRIBUTE = DispatcherServlet.class.getName() + ".FLASH_MAP_MANAGER";
/**
* Name of request attribute that exposes an Exception resolved with an
* {@link HandlerExceptionResolver} but where no view was rendered
* (e.g. setting the status code).
*/

public static final String EXCEPTION_ATTRIBUTE = DispatcherServlet.class.getName() + ".EXCEPTION";

以上这些静态final的字符串成员变量是各种属性名。
/** Log category to use when no mapped handler is found for a request. */

public static final String PAGE_NOT_FOUND_LOG_CATEGORY = "org.springframework.web.servlet.PageNotFound";

这个静态final的字符串属性实际上就是在请求找不到资源时打印出来的字符串。
/**
* Name of the class path resource (relative to the DispatcherServlet class)
* that defines DispatcherServlet's default strategy names.
*/

private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties";

这个静态final的字符串属性是配置文件名,该配置文件在同一包下,也就是这个包org.springframework.web.servlet
/** Additional logger to use when no mapped handler is found for a request. */

protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);

这个静态final的Log对象是请求找不到匹配的handler时的日志工具,将上面那个变量传入,以便在找不到资源时打印出相应字符串。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: