@RequestParam和@RequestBody的区别

@RequestBody是用来接收

application/json
需要解析json字符串,然后通过json获取参数,这里用到是fastjson
public CommonReturnType login(@RequestBody String jsonStr)  {
        JSONObject requestJson = JSON.parseObject(jsonStr);
        String telphone=(String)requestJson.get("telphone");
        String password=(String)requestJson.get("password");
}

 

@RequestParam是用来接收

  application/x-www-form-urlencoded
  可直接获取参数
public CommonReturnType login(
@RequestParam(name="telphone") String telphone,
@RequestParam(name="password") String password) { System.out.println(telphone+password) }

 

 

 

 





posted @ 2019-08-22 10:14  LLC-Mite  阅读(812)  评论(0编辑  收藏  举报