HttpRequestMethodNotSupportedException: Request method ‘POST‘ not supported

  • Post author:
  • Post category:其他


HttpRequestMethodNotSupportedException: Request method ‘POST’ not supported



一、问题

遇到Request method ‘POST’ not supported问题,无法定位到哪个接口导致的



二、解决办法

@Slf4j
@RestControllerAdvice
public class GlobalExceptionAdvice {
	/*
	* 捕捉异常HttpRequestMethodNotSupportedException
	*/
    @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
    public R handleValidException(HttpRequestMethodNotSupportedException exception, HttpServletRequest req) {
        log.warn("HttpRequestMethodNotSupportedException{},{},{}",
            exception.getClass(),
            exception.getMessage(),
            req.getRequestURL().toString());
        return R.error();
    }
}



三、参考链接

1、

Request method ‘POST’ not supported



版权声明:本文为chen_heng_Ali原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。