spring mvc 源代码笔记1--org.springframework.web.servlet.mvc.method
来源:互联网 发布:网络推广团队口号 编辑:程序博客网 时间:2024/06/06 23:07
实验室的项目用到了Spring MVC,决定看一下spring mvc 3.1.1的源代码,充充血。
首先先看了org.springframework.web.servlet工程下的org.springframework.web.servlet.mvc.method包。
RequestMappingInfo.java(主要存放HttpRequest信息,headers,patterns,consumes,produces,methods相关的)下有:
public RequestMappingInfo(PatternsRequestCondition patterns,
RequestMethodsRequestCondition methods,
ParamsRequestCondition params,
HeadersRequestCondition headers,
ConsumesRequestCondition consumes,
ProducesRequestCondition produces,
RequestCondition<?> custom) {
this.patternsCondition = patterns != null ? patterns : new PatternsRequestCondition();
this.methodsCondition = methods != null ? methods : new RequestMethodsRequestCondition();
this.paramsCondition = params != null ? params : new ParamsRequestCondition();
this.headersCondition = headers != null ? headers : new HeadersRequestCondition();
this.consumesCondition = consumes != null ? consumes : new ConsumesRequestCondition();
this.producesCondition = produces != null ? produces : new ProducesRequestCondition();
this.customConditionHolder = new RequestConditionHolder(custom);
}
自己倒是可能直接就赋值了!
get:判断入参是否为空!
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && obj instanceof RequestMappingInfo) {
RequestMappingInfo other = (RequestMappingInfo) obj;
return (this.patternsCondition.equals(other.patternsCondition) &&
this.methodsCondition.equals(other.methodsCondition) &&
this.paramsCondition.equals(other.paramsCondition) &&
this.headersCondition.equals(other.headersCondition) &&
this.consumesCondition.equals(other.consumesCondition) &&
this.producesCondition.equals(other.producesCondition) &&
this.customConditionHolder.equals(other.customConditionHolder));
}
return false;
}
override equals方法时,也用到了<<java核心技术里面>>提到的过程。
在这个类里面,页=也重写了hashCode(),看到用了31,防止hash冲突。
get:31是素数;31*N可以变成N<<5-N且5bit;
- spring mvc 源代码笔记1--org.springframework.web.servlet.mvc.method
- spring mvc中org.springframework.web.servlet.DispatcherServlet类
- spring mvc中org.springframework.web.servlet.DispatcherServlet类
- org.springframework.web.servlet.mvc.support.RedirectAttributes
- org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- spring源代码分析之org.springframework.web.method.support.HandlerMethodReturnValueHandler
- spring MVC关于org.springframework.web.servlet.handler.SimpleUrlHandlerMapping的使用
- Spring MVC: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet
- Spring MVC with Maven - java.lang.ClassNotFoundException: org.springframework.web.servlet.Dispatcher
- 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0'
- 废弃的org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- spring mvc org.springframework.beans.NullValueInNestedPathException错误
- maven springmvc Error creating bean with name 'org.springframework.web.servlet.mvc.annotation
- spring mvc 在web请求中定义编码(org.springframework.web.filter.CharacterEncodingFilter
- 解读Spring源代码(Web MVC)
- Spring MVC报异常:org.springframework.web.util.NestedServletException: Request processing failed
- 新人励志篇
- hibernate工作原理
- android 简单的手电筒制作
- poj 1654 Area
- 信息: Initializing Spring root WebApplicationContext
- spring mvc 源代码笔记1--org.springframework.web.servlet.mvc.method
- 学习《笨办法学phyton》(0)
- 读核笔记-内核初始化-从start_kernel到init
- oracle表分区
- 自己的usaco代码---PROB Calf Flac
- X Shell 4配色方案[Solarized Dark]
- 不要自称为程序员
- HDU4662+无
- java日期操作