Spring JSON request body not mapped to Java POJO

前端 未结 5 986
终归单人心
终归单人心 2020-12-29 04:54

I\'m using Spring to implement a RESTful web service. One of the endpoints takes in a JSON string as request body and I wish to map it to a POJO. However, it seems right now

5条回答
  •  别那么骄傲
    2020-12-29 05:21

    Sample Data :

    [  
    {  
      "targetObj":{  
         "userId":1,
         "userName":"Devendra"
      }
    },
    {  
      "targetObj":{  
         "userId":2,
         "userName":"Ibrahim"
      }
    },
    {  
      "targetObj":{  
         "userId":3,
         "userName":"Suraj"
      }
    }
    ]
    

    For above data this pring controller method working for me:

    @RequestMapping(value="/saveWorkflowUser", method = RequestMethod.POST)
    public void saveWorkflowUser (@RequestBody List>> userList )  {
        System.out.println(" in saveWorkflowUser : "+userList);
     //TODO now do whatever you want to do.
    }
    

提交回复
热议问题