Method Not Allowed","message":"Request method 'POST' not supported","path":"/**/**"

使用feign是有遇到报:

 Method Not Allowed","message":"Request method 'POST' not supported","path":"/**/**"

可是代码里面明明写的是Get请求,

报错的地方:

 @GetMapping("/product/listForOrder")
 List<ProductInfo> listForOrder(@RequestBody List<String> productIdList);

报错原因:@RequestBody要用 @PostMapping方式;

修改之后:

 @PostMapping("/product/listForOrder")
 List<ProductInfo> listForOrder(@RequestBody List<String> productIdList);

总结:

@RequestBody-------------> @PostMapping

@RequestParam 、@PathVariable------@GetMapping

猜你喜欢

转载自blog.csdn.net/qq_37746483/article/details/82382707