Annotation-based argument resolution 部分2
HandlerMethodArgumentResolver的抽象實現AbstractNamedValueMethodArgumentResolver下的子类 部分1
RequestParamMapMethodArgumentResolver
// 存在@RequestParam注解并且该注解中name属性无值
public boolean supportsParameter(MethodParameter parameter) {
RequestParam requestParam = parameter.getParameterAnnotation(RequestParam.class);
return (requestParam != null && Map.class.isAssignableFrom(parameter.getParameterType()) &&
!StringUtils.hasText(requestParam.name()));
} 可以使用以下6中方式接收参数
MultiValueMap<String, MultipartFile> 相当于==》 Map<String, List<MultipartFile>>
LinkedMultiValueMap<String, Part> 相当于==> LinkedHashMap<String, List<Part>>
MultiValueMap<String, String> 相当于==> Map<String, List<String>> Map<String, MultipartFile>
LinkedHashMap<String, Part>
Map<String, String> PathVariableMapMethodArgumentResolver
public boolean supportsParameter(MethodParameter parameter) {
PathVariable ann = parameter.getParameterAnnotation(PathVariable.class);
return (ann != null && Map.class.isAssignableFrom(parameter.getParameterType()) &&
!StringUtils.hasText(ann.value()));
} 如下方式使用:
@PathVariable LinkedHashMap<String, String> paths MatrixVariableMapMethodArgumentResolver
// 存在@MatrixVariable注解并且该注解中name属性无值
public boolean supportsParameter(MethodParameter parameter) {
MatrixVariable matrixVariable = parameter.getParameterAnnotation(MatrixVariable.class);
return (matrixVariable != null && Map.class.isAssignableFrom(parameter.getParameterType()) &&
!StringUtils.hasText(matrixVariable.name()));
} // 以下使用方式 MultiValueMap<String, String> RequestHeaderMapMethodArgumentResolver
// 存在@RequestHeader 并且 参数类型为Map.class.isAssignableFrom
public boolean supportsParameter(MethodParameter parameter) {
return (parameter.hasParameterAnnotation(RequestHeader.class) &&
Map.class.isAssignableFrom(parameter.getParameterType()));
} 以下方式使用,使用如下参数类型:
MultiValueMap<String, String>
HttpHeaders
Map<String, String> RequestPartMethodArgumentResolver // 接收@RequestPart 并且不能包含 @ReqeusatParam
// 并且满足 MultipartResolutionDelegate.isMultipartArgument 以下类型 也可以通过:
MultipartFile
List<MultipartFile>
MultipartFile[]
Part
List<Part>
Part[] @Override
public boolean supportsParameter(MethodParameter parameter) {
if (parameter.hasParameterAnnotation(RequestPart.class)) {
return true;
}
else {
if (parameter.hasParameterAnnotation(RequestParam.class)) {
return false;
}
return MultipartResolutionDelegate.isMultipartArgument(parameter.nestedIfOptional());
}
} 注解之后使用一下方式接收参数值:
MultipartFile
List<MultipartFile>
MultipartFile[]
Part
List<Part>
Part[] ServletModelAttributeMethodProcessor RequestResponseBodyMethodProcessor
Annotation-based argument resolution 部分2的更多相关文章
- An annotation based command line parser
Java命令行选项解析之Commons-CLI & Args4J & JCommander http://rensanning.iteye.com/blog/2161201 JComm ...
- [转载]Spring Annotation Based Configuration
Annotation injection is performed before XML injection, thus the latter configuration will override ...
- spring Annotation based configuration
spring 注解相关 https://docs.spring.io/spring/docs/3.0.0.M3/reference/html/ch04s11.html
- 译:Spring框架参考文档之IoC容器(未完成)
6. IoC容器 6.1 Spring IoC容器和bean介绍 这一章节介绍了Spring框架的控制反转(IoC)实现的原理.IoC也被称作依赖注入(DI).It is a process wher ...
- springmvc 请求参数解析细节
springmvc 的请求流程,相信大家已经很熟悉了,不熟悉的同学可以参考下资料! 有了整体流程的概念,是否对其中的实现细节就很清楚呢?我觉得不一定,比如:单是参数解析这块,就是个大学问呢? 首先,我 ...
- 摘抄JPA官方文档原文 防呆
Spring Data JPA - Reference Documentation Oliver GierkeThomas DarimontChristoph StroblMark PaluchVer ...
- SpringMVC深度探险(二) —— SpringMVC概览
对于任何事物的研究,总是由表及里.由浅入深地进行.在本系列的第二篇文章中,我们将通过不同的观察视角,对SpringMVC做一些概要性的分析,帮助大家了解SpringMVC的基本构成要素.SpringM ...
- Spring MVC之源码速读之RequestMappingHandlerAdapter
spring-webmvc-4.3.19.RELEASE 下面来看DispatcherServlet中的执行: /** * Exposes the DispatcherServlet-specific ...
- Spring框架文档与API(4.3.6版本)
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/ Table of Contents I ...
随机推荐
- AES加密解密工具类封装(AESUtil)
package club.codeapes.common.utils; import org.springframework.util.Base64Utils; import javax.crypto ...
- MySQL的JOIN连接
MySQL的JOIN join的含义跟英文单词"join"一样,连接连接两张表.分为 内连接:inner join 外连接 (1)左外连接(左边的表不加限制):left joi ...
- web服务器-nginx
一.nginx之前 同步与异步: 同步与异步的重点在消息通知的方式上,也就是调用结果的通知方式不同. 同步:当一个同步调用发出去后,调用者要一直等待调用的结果通知后,才能进行后续的操作. 异步:当一个 ...
- Python xlrd模块读取Excel表中的数据
1.xlrd库的安装 直接使用pip工具进行安装(当然也可以使用pycharmIDE进行安装,这里就不详述了) pip install xlrd 2.xlrd模块的一些常用命令 ①打开excel文件并 ...
- Httpd服务入门知识-正向代理和反向代理
Httpd服务入门知识-正向代理和反向代理 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.正向代理和反向代理 启用反向代理 ProxyPass "/" &q ...
- gitlab修改IP地址及仓库地址
将IP修改为192.168.10.100,操作方法 . 先修改本地的IP地址 vim /etc/sysconfig/network-scripts/ifcfg-eth0TYPE=EthernetBOO ...
- nginx重试机制proxy_next_upstream
nginx作为反向代理服务器,后端RS有多台服务器,上层通过一定机制保证容错和负载均衡. nginx的重试机制就是容错的一种 官方链接:http://nginx.org/en/docs/http/ng ...
- Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value
Cause: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value: '154 ...
- com.alibaba.fastjson.JSONException: exepct '[', but error, pos 1, json : %255B%257B%2522list%2522%253A%255B%257B%2522itemId%2522%253A1369331%252C%2522num%2522%253A2%257D%255D%257D%255
com.alibaba.fastjson.JSONException: exepct '[', but error, pos 1, json : %255B%257B%2522list%2522%25 ...
- 修复wecenter移动版description首页描述一样问题
因网友要求,wecenter移动版description首页描述一样,所以在此写个教程,希望帮助大家! 修改方法 打开app/m/main.php TPL::output('m/question'); ...