发具体的页面。 6)视图View(需要工程师开发)
View是一个接口,实现类支持不同的View类型(jsp、freemarker、pdf...)
注意:处理器Handler(也就是我们平常说的Controller控制器)以及视图层view都是需要我们自己手动开发的。其他的一些组件比如:前端控制器DispatcherServlet、处理器映射器HandlerMapping、处理器适配器HandlerAdapter等等都是框架提供给我们的,不需要自己手动开发。 六、DispatcherServlet详细解析
首先看下源码:
package org.springframework.web.servlet;
@SuppressWarnings("serial")
public class DispatcherServlet extends FrameworkServlet {
public static final String MULTIPART_RESOLVER_BEAN_NAME = "multipartResolver";
public static final String LOCALE_RESOLVER_BEAN_NAME = "localeResolver";
public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver";
public static final String HANDLER_MAPPING_BEAN_NAME = "handlerMapping";
public static final String HANDLER_ADAPTER_BEAN_NAME = "handlerAdapter";
public static final String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME = "handlerExceptionResolver";
public static final String REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME = "viewNameTranslator";
public static final String VIEW_RESOLVER_BEAN_NAME = "viewResolver";
public static final String FLASH_MAP_MANAGER_BEAN_NAME = "flashMapManager";
public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE = DispatcherServlet.class.getName() + ".CONTEXT";
public static final String LOCALE_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".LOCALE_RESOLVER";
public static final String THEME_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_RESOLVER";
public static final String THEME_SOURCE_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_SOURCE";
public static final String INPUT_FLASH_MAP_ATTRIBUTE = DispatcherServlet.class.getName() + ".INPUT_FLASH_MAP";
public static final String OUTPUT_FLASH_MAP_ATTRIBUTE = DispatcherServlet.class.getName() + ".OUTPUT_FLASH_MAP";
public static final String FLASH_MAP_MANAGER_ATTRIBUTE = DispatcherServlet.class.getName() + ".FLASH_MAP_MANAGER";
public static final String EXCEPTION_ATTRIBUTE = DispatcherServlet.class.getName() + ".EXCEPTION";
public static final String PAGE_NOT_FOUND_LOG_CATEGORY = "org.springframework.web.servlet.PageNotFound";
private static final String DEFAULT_STRATEGIES_PATH = "DispatcherServlet.properties";
protected static final Log pageNotFoundLogger = LogFactory.getLog(PAGE_NOT_FOUND_LOG_CATEGORY);
private static final Properties defaultStrategies;
static {
try {
ClassPathResource resource = new ClassPathResource(DEFAULT_STRATEGIES_PATH, DispatcherServlet.class);
defaultStrategies = PropertiesLoaderUtils.loadProperties(resource);
}catch (IOException ex) {
throw new IllegalStateException("Could not load 'DispatcherServlet.properties': " + ex.getMessage());
}
}
/ Detect all HandlerMappings or just expect "handlerMapping" bean? /
private boolean detectAllHandlerMappings = true;
/ Detect all HandlerAdapters or just expect "handlerAdapter" bean? /
private boolean detectAllHandlerAdapters = true;
/* Detect all HandlerExceptionResolvers or just expect "handlerExceptionResolver" bean? /
private boolean detectAllHandlerExceptionResolvers = true;
/ Detect all ViewResolvers or just expect "viewResolver" bean? /
private boolean detectAllViewResolvers = true;
/Throw a NoHandlerFoundException if no Handler was found to process this request? /
private boolean throwExceptionIfNoHandlerFound = false;
/ Perform cleanup of request attributes after include request? /
private boolean cleanupAfterInclude = true;
/* MultipartResolver used by this servlet /
private MultipartResolver multipartResolver;
/ LocaleResolver used by this servlet /
private LocaleResolver localeResolver;
/ ThemeResolver used by this servlet /
private ThemeResolver themeResolver;
/* List of HandlerMappings used by this servlet /
private List<HandlerMapping> handlerMappings;
/* List of HandlerAdapters used by this servlet /
private List<HandlerAdapter> handlerAdapters; 面试资料整理汇总