Spring: How to get parameters from POST body?

前端 未结 6 933
庸人自扰
庸人自扰 2020-12-29 06:00

Web-service using spring in which I have to get the params from the body of my post request? The content of the body is like:-

source=”mysource”

&json=
         


        
6条回答
  •  -上瘾入骨i
    2020-12-29 06:42

    You can try using @RequestBodyParam

    @RequestMapping(value = "/saveData", headers="Content-Type=application/json", method = RequestMethod.POST)
    @ResponseBody
    public ResponseEntity saveData(@RequestBodyParam String source,@RequestBodyParam JsonDto json) throws MyException {
        ...
    }
    

    https://github.com/LambdaExpression/RequestBodyParam

提交回复
热议问题