@ResponseBody
@DeleteMapping("account/{id}")
public Map<String,String> deleteAccountById(@PathVariable Integer id) {
int row=accountService.delAccount(id);
Map<String,String> map=new HashMap<>();
if(row>0) {
map.put("code","200");
map.put("msg","删除成功");
}else {
map.put("code","500");
map.put("msg","删除失败");
}
return map;
}
查询部分:
@ResponseBody
@GetMapping("account/{id}")
// @RequestMapping("account/queryAccountById")
public Account queryAccountById(@PathVariable Integer id) {
return accountService.queryById(id);
}
可以发现两者的路径相同,去浏览器访问:
实现的是查询操作
因为浏览器去请求时做的就是一个GET请求