message:Request method 'POST' not supported

版权声明:转载请注明出处和署名,谢谢! https://blog.csdn.net/MobiusStrip/article/details/82749690

message:Request method ‘POST’ not supported

There was an unexpected error (type=Internal Server Error, status=500).
status 405 reading UserFeignClient#getUser(User); content: {“timestamp”:“2018-09-07T09:01:14.290+0000”,“status”:405,“error”:“Method Not Allowed”,“message”:“Request method ‘POST’ not supported”,“path”:"/feign-get-user"}

  • 错误原因:
    该请求不会成功,只要参数是复杂对象,即使指定了是GET方法,feign依然会以POST方法进行发送请求。可能是我没找到相应的注解或使用方法错误。

  • 解决办法:

	// 该请求不会成功,只要参数是复杂对象,即使指定了是GET方法,feign依然会以POST方法进行发送请求。可能是我没找到相应的注解或使用方法错误。
	@RequestMapping(method = RequestMethod.GET, value = "/feign-get-user")
	public User getUser(User user);
	
	//正确用法
	@RequestMapping(method = RequestMethod.GET, value = "/feign-get-user")
	public User getUser(@RequestParam("id") Long id, @RequestParam("username") String username, @RequestParam("age") String age);
}

猜你喜欢

转载自blog.csdn.net/MobiusStrip/article/details/82749690