@RequestParam ——多个参数
// 后端 Springboot
@GetMapping("/orders/selectAll")
public String getAllOrders(@RequestParam("uid") String uid, @RequestParam("status") String status) {
// 处理参数
return "Received UID: " + uid + ", Status: " + status;
}
// 前端js
this.$request.get('/orders/selectByUidAndStatus?uid=' + this.user.id + '&status=' + 'stay').then(res => {
if (res.code === '200') {
this.unStayOrdersMsg = res.data || []
} else {
console.log(res.msg)
}
})
@RequestBody —— 整个对象
@PathVariable —— 单个参数
/**
* 批量删除
*/
@DeleteMapping("/delete/batch")
public Result deleteBatch(@RequestBody List<Integer> ids) {
ordersService.deleteBatch(ids);
return Result.success();
}
/**
* 删除
*/
@DeleteMapping("/delete/{id}")
public Result deleteById(@PathVariable Integer id) {
collectService.deleteById(id);
return Result.success();
}
前端js
http://localhost:9090/collect/delete/44
this.$request.delete('/collect/delete/batch', {data: this.ids}).then(res = >{})
this.$request.delete('/collect/delete/' + id).then(res => {