@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) }
原文地址:https://www.cnblogs.com/llcMite/p/11392790.html
时间: 2024-11-05 23:37:55