@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?

相关文章:

  • 2021-04-17
  • 2022-12-23
  • 2022-02-04
  • 2022-03-10
  • 2021-09-03
  • 2022-03-09
  • 2022-03-04
  • 2021-11-09
猜你喜欢
  • 2022-12-23
  • 2021-08-21
  • 2021-07-01
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案