>  Q&A  >  본문

java - Springmvc中@RequestBody和@RequestParam能够同时使用吗

 @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中文网2714일 전675

모든 응답(2)나는 대답할 것이다

  • PHP中文网

    PHP中文网2017-04-17 17:56:20

    으아악

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-17 17:56:20


    예:
    json 데이터를
    http://www.google.com?code=1024

    에 게시하세요.

    RequestParams는 코드=1024
    RequestBody는 json 데이터입니다(주제 제외: 콘텐츠 유형에 주의하세요)

    회신하다
    0
  • 취소회신하다