1、后台接收数据格式
List<User> userList;
postman格式:
{
"userList":[{"userId":"3","age":"14"}]
}
注意:前后端userList名字要保持一致,否则后台接收的数据为“null”。
2、后台接收数据格式
@PathVariable("userId")
@RequestMapping(value = "/getUser/{userId}",method = RequestMethod.POST)
public User getUserById(@PathVariable("userId") Long userId){
return null;
}
postman格式:(url中直接拼接id即可-通过“/”拼接)
/getUser/8
注意:PathVariable()中限定只能传参数userId。
3、后台接收数据格式
@RequestParam("teacherId")
@RequestMapping(value = "/queryStudentsListByTeacherId",method = RequestMethod.POST)
public <List<Student>> queryStudentsListByTeacherId(@RequestParam("teacherId") Long teacherId){
return null;
}
postman格式:(url中直接拼接id即可,通过“?”拼接,“?teacherId=76”也相当于postman中的json格式传输数据)
/queryStudentListByTeacherId?teacherId=76
注意:RequestParam()中限定只能传参数teacherId。
4、后台接收数据格式
@RequestParam("param")
@RequestMapping(value = "/tem",method = RequestMethod.POST)
public void tem(@RequestParam("param") String param){
}
postman格式:
postman中通过form-data格式传输数据:
注意:RequestParam("param")中限定只能传参数param。