@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的更多相关文章

  1. Spring @RequestParam @RequestBody @PathVariable 等参数绑定注解详解

    背景 昨天一个人瞎倒腾spring boot,然后遇到了一点问题,所以把这个问题总结一下. 主要讲解request 数据到handler method 参数数据的绑定,所用到的注解和什么情形下使用. ...

  2. Spring @RequestParam、@RequestBody和@ModelAttribute区别

    一.@RequestParamGET和POST请求传的参数会自动转换赋值到@RequestParam 所注解的变量上1. @RequestParam(org.springframework.web.b ...

  3. Spring @RequestParam乱码问题

    在网上找了很多资料才找到解决的方法,通过URL传递命名参数,后台接收的却是乱码解决方法如下: 方法一:将接收的参数重新编码 @RequestMapping(value="/handle&qu ...

  4. spring mvc 框架启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal 解决办法

    今天准备将以前自己搭建的一个框架拿出来用一下,结果发现启动报错:nested exception is java.lang.NoClassDefFoundError: org/w3c/dom/Elem ...

  5. Spring框架文档与API(4.3.6版本)

    http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/ Table of Contents I ...

  6. Spring Boot Reference Guide

    Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch,  ...

  7. Spring boot参考指南

    介绍 转载自:https://www.gitbook.com/book/qbgbook/spring-boot-reference-guide-zh/details 带目录浏览地址:http://ww ...

  8. 20191128 Spring Boot官方文档学习(9.4-9.8)

    9.4.Spring MVC Spring Boot有许多启动器包含Spring MVC.请注意,一些启动器包括对Spring MVC的依赖,而不是直接包含它. 9.4.1.编写JSON REST服务 ...

  9. SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)【转载】

    最近在学习Spring+SpringMVC+MyBatis的整合.以下是参考网上的资料自己实践操作的详细步骤. 1.基本概念   1.1.Spring Spring是一个开源框架,Spring是于20 ...

随机推荐

  1. 常用的shell命令整理

    工作快一年了,shell命令也玩了一年了.还是有点积累的,下面是本人常用的. 1.pwd | xargs -i basename {}   获取当前所在目录的名称 2.ps -ef|grep -w   ...

  2. 平实给力的写作指导入门手冊——leo鉴书57

    写作是个体力活儿,须要不断的练习和砥砺.既然是体力劳动,那必定有套路,前人总结.后人学习并加以积累沉积,日久则形成不同的风格和流派有点儿像.相同,写作也有自己的套路和学习路径.初涉写作有必备之书吗?当 ...

  3. java中将list、map对象写入文件

    链接地址:http://blog.sina.com.cn/s/blog_4a4f9fb50101p6jv.html     推荐:凤爪女瓜子男怪象该谁反思伦敦房价为什么持续暴涨 × wvqusrtg个 ...

  4. thiscall仅仅应用于“C++”成员函数(this指针存放于CX寄存器,参数从右到左压)

    _stdcall是Pascal程序的缺省调用方式,通常用于Win32 Api中,函数采用从右到左的压栈方式,自己在退出时清空堆栈.VC将函数编译后会在函数名前面加上下划线前缀,在函数名后加上" ...

  5. Impossible WPF Part 1: Binding Properties

    原文 http://www.11011.net/wpf-binding-properties Ever wanted to write the following? <RichTextBoxDo ...

  6. iOS WebCore的WebEvent和EventHandler

    WebEvent是iOS专有的类,负责封装和携带从UIKit得到的系统事件信息,并由WebKit层的WAKResponder子类传递到WebCore的EventHandler. UIKit层的逻辑可参 ...

  7. stm32之CAN总线基础

    can总线协议概述: CAN是Controller Area Network的缩写,由德国博世公司开发:CAN通过ISO11891以及ISO11519进行了标准化:     CAN总线的特点: 1.多 ...

  8. Triangle---minimum path sum

    动态规划 class Solution: # @param triangle, a list of lists of integers # @return an integer def minimum ...

  9. Smarty模板Windows下写代码 放到CentOS6.5无法正确解析

    如题:报错: Unable to load template file 'System/header.htm' in '/var/www/website/cms/Template/Default/We ...

  10. 演练5-3:Contoso大学校园管理系统3

    在前面的教程中,我们使用了一个简单的数据模型,包括三个数据实体.在这个教程汇中,我们将添加更多的实体和关系,按照特定的格式和验证规则等自定义数据模型. Contoso大学校园管理系统的数据模型如下. ...