Anfrage erhalten
Das Backend dient @RequestParam
zum Empfangen von Daten und das Frontend params
zum Senden von Daten
. Backend:
@GetMapping
public Result checkHadTou(@RequestParam Integer id, @RequestParam String brand){
System.out.println(id + " and " + brand);
return null;
}
Frontend:
this.$axios.get("/toubiao", {
params :{
id: this.IwantTouForm.targetId,
brand: this.IwantTouForm.brand
}}).then(res=>{
console.log(res.data)
})
Die Löschanforderung sendet das Array an das Backend
Front-End-Anfragecode:
this.$axios({
url: '/toubiao',
method: 'delete',
data: ids
})
.then(res=>{
console.log(res.data)
})
Der Back-End-Empfangscode:
Es ist eine Falle,接收需要使用list并且还要指定类型
/**
* 按id批量删除
* @param ids
* @return
*/
@DeleteMapping
public Result removeByIds(@RequestBody List<Integer> ids){
System.out.println( "获取到的数组:"+ ids);
return null;
}