Customize Spring @RequestParam Deserialization for Maps and/or Nested Objects
@RestController
class MyController {
@RequestMapping(...)
public void test(Container container) { ... }
}
Spring by default uses Dot-Notation to deserialize a nested @RequestParam:
class Container {
A a;
}
class A {
String val;
}
works with:
http://.../myController?a.val=foo
But for Maps it uses Square Bracket notation:
class Container {
Map<String, String> a;
}
works with:
http://.../myController?a[val]=foo
When using JavaScript there's of course no difference between a HashMap and a Nested Object, so everything will get serialized either with Dots or Square-Brackets.
Question:
How / where can I tell Spring (or Spring Boot if that's easier) to use Dot-Notation (or Square Brackets) for both, nested objects and Maps?
Or is there any reason why Spring makes a difference between those types?
Customize Spring @RequestParam Deserialization for Maps and/or Nested Objects的更多相关文章
- Spring @RequestParam @RequestBody @PathVariable 等参数绑定注解详解
背景 昨天一个人瞎倒腾spring boot,然后遇到了一点问题,所以把这个问题总结一下. 主要讲解request 数据到handler method 参数数据的绑定,所用到的注解和什么情形下使用. ...
- Spring @RequestParam、@RequestBody和@ModelAttribute区别
一.@RequestParamGET和POST请求传的参数会自动转换赋值到@RequestParam 所注解的变量上1. @RequestParam(org.springframework.web.b ...
- Spring @RequestParam乱码问题
在网上找了很多资料才找到解决的方法,通过URL传递命名参数,后台接收的却是乱码解决方法如下: 方法一:将接收的参数重新编码 @RequestMapping(value="/handle&qu ...
- spring mvc 框架启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal 解决办法
今天准备将以前自己搭建的一个框架拿出来用一下,结果发现启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/Elem ...
- Spring框架文档与API(4.3.6版本)
http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/ Table of Contents I ...
- Spring Boot Reference Guide
Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, ...
- Spring boot参考指南
介绍 转载自:https://www.gitbook.com/book/qbgbook/spring-boot-reference-guide-zh/details 带目录浏览地址:http://ww ...
- 20191128 Spring Boot官方文档学习(9.4-9.8)
9.4.Spring MVC Spring Boot有许多启动器包含Spring MVC.请注意,一些启动器包括对Spring MVC的依赖,而不是直接包含它. 9.4.1.编写JSON REST服务 ...
- SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)【转载】
最近在学习Spring+SpringMVC+MyBatis的整合.以下是参考网上的资料自己实践操作的详细步骤. 1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于20 ...
随机推荐
- zzuli生化危机(dfs)
生化危机 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 73 Solved: 21SubmitStatusWeb Board Description ...
- 【转】linux挂载新硬盘,开机自动挂载
[转]linux挂载新硬盘,开机自动挂载 ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ Linux的硬盘识别: 2.6 kernel以后,linux会将 ...
- 第一篇:NSTread线程的创建
#import "ViewController.h" //导入头文件 #import <pthread.h> @interfaceViewController () @ ...
- week4_motion_of_ball_1(小球运动)——最基本
# Ball motion with an explicit timer import simplegui # Initialize globals width = 600 height = 600 ...
- ASP.NET MVC 以Stream 下载文件
1.0以Stream 下载文件 nl.fileid = Int32.Parse(id); //服务器上对应的id Stream stream = Lawsuit.DownLoad(nl);//服务器 ...
- Windows服务编程集合
http://zyan.cc/windows_mstsc/ Optionname--Optionvalues描述 type=----own, share, interact, kernel, file ...
- Jquery的text()和html()方法在li与div取值结果解析
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- shell 脚本阅读之二——ltp工具下的runltp
#!/bin/sh ################################################################################ ## ## ## ...
- Android平台下使用lua调用Java代码经验总结
动态语言以其执行的灵活性,可配置性.方便调试能够为开发带来极大的方便.假设用好了.能够极大的提高开发的效率. 怪不得像游戏开发这样复杂的软件开发里没有不集成脚本语言的. 当中,lua以其小巧,灵活.方 ...
- UVA - 10057 A mid-summer night's dream.
偶数时,中位数之间的数都是能够的(包含中位数) 奇数时,一定是中位数 推导请找初中老师 #include<iostream> #include<cstdio> #include ...