后端获取前台参数的几种方法

1.前台通过URL传递,后端利用@RequestParam来接收
serverUrl + '/items/refresh?itemSpecIds=' + itemSpecIds
@GetMapping("/refresh")
public void refresh(
        @RequestParam String itemSpecIds) {}

 

2.前台通过url\传递,后台通过@PathVariable来接收
serverUrl + '/index/sixNewItems/' + rootCatId, {}
@GetMapping("/sixNewItems/{rootCatId}")
public void sixNewItems(
        @PathVariable Integer rootCatId) {}

 

3.前台通过body中json传递,后台通过@RequestBody来接收
axios.post(serverUrl + '/passport/regist', userBO)
public void PostMapping(@RequestBody UserBO userBO){}

 

 

你可能感兴趣的:(java,java)