一、问题
遇到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();
}
}