您的位置:首页 > 移动开发 > Objective-C

Customize Spring @RequestParam Deserialization for Maps and/or Nested Objects

2015-11-16 11:31 751 查看
@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?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: