get请求
后端使用 @RequestParam
接收数据,前端使用 params
发送数据
后端:
@GetMapping
public Result checkHadTou(@RequestParam Integer id, @RequestParam String brand){
System.out.println(id + " and " + brand);
return null;
}
前端:
this.$axios.get("/toubiao", {
params :{
id: this.IwantTouForm.targetId,
brand: this.IwantTouForm.brand
}}).then(res=>{
console.log(res.data)
})
delete请求发送数组到后端
前端请求代码:
this.$axios({
url: '/toubiao',
method: 'delete',
data: ids
})
.then(res=>{
console.log(res.data)
})
后端接收代码:
踩坑啊,接收需要使用list并且还要指定类型
/**
* 按id批量删除
* @param ids
* @return
*/
@DeleteMapping
public Result removeByIds(@RequestBody List<Integer> ids){
System.out.println( "获取到的数组:"+ ids);
return null;
}