java - Springmvc中@RequestBody和@RequestParam能够同时使用吗
PHP中文网
PHP中文网 2017-04-17 17:54:20
0
2
637
@RequestMapping(value = "", method = RequestMethod.POST) public Result get(@RequestBody User user, @RequestParam("username") String hehe) throws Exception { }

如何能够接受user对象的同时,同时接受username?

假设User对象为

public class User { private String id; private String username; private String email; private String phone; }
PHP中文网
PHP中文网

认证高级PHP讲师

reply all (2)
Ty80
post http://url?username=123 { id: "", username: "", email: "", phone: "" }
    洪涛

    Yes
    For example:
    post a json data to
    http://www.google.com?code=1024

    RequestParams is code=1024
    RequestBody is your json data (off-topic: pay attention to content-type)

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!