Automatic conversion of JSON form parameter in Spring MVC 4.0

后端 未结 2 1213
一向
一向 2021-02-06 01:03

I am trying to build a Spring MVC controller which will receive a POSTed form with a parameter in JSON format, and have Spring automatically convert it to a Java object.

2条回答
  •  天涯浪人
    2021-02-06 01:30

    You can also use @RequestPart like this:

    @RequestMapping(value = "/issues", method = RequestMethod.POST, headers = "Content-Type=multipart/form-data")
    public String uploadIssue(@RequestParam("image") MultipartFile file, @RequestPart("issue") MyMessage issue)
    

提交回复
热议问题