zoukankan      html  css  js  c++  java
  • 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?

  • 相关阅读:
    跑路了
    *CTF 2019 quicksort、babyshell、upxofcpp
    pyspark如何遍历broadcast
    pwn易忘操作原理笔记
    pwn学习之四
    pwn学习之三
    pwn学习之二
    pwn学习之一
    2017GCTF部分writeup
    OD使用教程12
  • 原文地址:https://www.cnblogs.com/duyinqiang/p/5696466.html
Copyright © 2011-2022 走看看