spring mvc 源代码笔记1--org.springframework.web.servlet.mvc.method
2013-08-16 22:33
591 查看
实验室的项目用到了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;
首先先看了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集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException
- 废弃的org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingH
- org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- [org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver]-[DEBUG] Re
- 废弃的org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter
- spring源代码分析之org.springframework.web.method.support.HandlerMethodReturnValueHandler
- org.springframework.web.servlet.mvc.support.RedirectAttributes
- Spring MVC: org.springframework.web.multipart.MultipartException: Could not parse multipart servlet
- org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry异常的解决方法
- springMVC:org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
- maven springmvc Error creating bean with name 'org.springframework.web.servlet.mvc.annotation
- Spring MVC with Maven - java.lang.ClassNotFoundException: org.springframework.web.servlet.Dispatcher
- Spring MVC报异常:org.springframework.web.util.NestedServletException: Request processing failed
- spring MVC关于org.springframework.web.servlet.handler.SimpleUrlHandlerMapping的使用
- Failed to instantiate [org.springframework.web.servlet.HandlerMapping]: Factory method 'webSocketHan
- Spring MVC报异常:org.springframework.web.util.NestedServletException: Request processing failed
- Spring MVC org.springframework.web.bind.MissingServletRequestParameterException解决办法
- org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupportedWARNING: Request met