Can I use @Requestparam annotation for a Post request?

前端 未结 5 812
名媛妹妹
名媛妹妹 2020-12-02 19:10

I have this controller method:

@PostMapping(
        value = \"/createleave\",
        params = {\"start\",\"end\",\"hours\",\"username\"})
public void creat         


        
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 19:29

    You should use @RequestBody instead of using @RequestParam And you should provide whole object as a body of request @RequestParam is to get data from URL

    you can do something like public saveUser(@RequestBody User user) { do something with user }

    and it will be mapped as User object for example

提交回复
热议问题