@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public R httpRequestMethodNotSupportedException(Exception e) {
logger.error(e.getMessage(), e);
return R.error(405, "请求方式不支持!");
}
此时的参数是
HttpRequestMethodNotSupportedException.class,表示只有抛出方法HttpRequestMethodNotSupportedException是才会调用该方法