共同学习SpringMVC源码--DispatcherServlet(二)
2016-06-01 21:58
393 查看
private static final Properties defaultStrategies;
这个静态final的Properties类是默认策略,所谓默认策略就是同一包下有个DispatcherServlet.properties文件,里面定义了一些属性,其实就是一些处理器的实现类的类名。
static {
// Load default strategy implementations from properties file.
// This is currently strictly internal and not meant to be customized
// by application developers.
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;
这些boolean变量代表是否检测所有变量名中detect之后的组件,true代表要检测所有,false的话只检测是不是有变量名中detect之后的那个bean。
/** Throw a NoHandlerFoundException if no Handler was found to process this request? **/
private boolean throwExceptionIfNoHandlerFound = false;
这个boolean变量代表如果没有找到handler,就抛异常,默认为false,也就是不抛异常。
/** Perform cleanup of request attributes after include request? */
private boolean cleanupAfterInclude = true;
这个boolean变量代表include方法调用后是否清楚request的属性。执行include方法的servlet执行完后,再返回到原来的servlet执行response的输出(如果有),就是PrintWriter在转发后仍然会继续输出,如果有要输出内容的话。
这个静态final的Properties类是默认策略,所谓默认策略就是同一包下有个DispatcherServlet.properties文件,里面定义了一些属性,其实就是一些处理器的实现类的类名。
static {
// Load default strategy implementations from properties file.
// This is currently strictly internal and not meant to be customized
// by application developers.
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;
这些boolean变量代表是否检测所有变量名中detect之后的组件,true代表要检测所有,false的话只检测是不是有变量名中detect之后的那个bean。
/** Throw a NoHandlerFoundException if no Handler was found to process this request? **/
private boolean throwExceptionIfNoHandlerFound = false;
这个boolean变量代表如果没有找到handler,就抛异常,默认为false,也就是不抛异常。
/** Perform cleanup of request attributes after include request? */
private boolean cleanupAfterInclude = true;
这个boolean变量代表include方法调用后是否清楚request的属性。执行include方法的servlet执行完后,再返回到原来的servlet执行response的输出(如果有),就是PrintWriter在转发后仍然会继续输出,如果有要输出内容的话。
相关文章推荐
- HashTable vs HashMap
- Java中运用数组的四种排序方法
- Titan java读数据的相关api使用 (初学)
- HashMap VS WeakHashMap
- spring的ioc之Resource
- java线程
- JavaSE基础之查找质数
- 通过Spring Resource接口获取资源
- spring InitializingBean接口
- Spring mvc的生命周期
- springMVC工作原理
- Garbage Collection in java
- Spring MVC 拦截 js,css,png 等资源
- 我的Eclipse快捷键.
- java-maven
- Spring整合Mybaties
- 【java并发】原子性操作类的使用
- Java | 原来 try 还可以这样用啊?!
- Java多线程创建方式
- Java常用排序算法之选择排序