sk-matrix-service 项目 添加 HttpRequestMethodNotSupportedException 异常处理
This commit is contained in:
parent
f54213d8ef
commit
7f3eea86ad
@ -8,6 +8,7 @@ import org.springframework.http.converter.HttpMessageNotReadableException;
|
|||||||
import org.springframework.validation.BindException;
|
import org.springframework.validation.BindException;
|
||||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||||
|
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
@ -29,6 +30,11 @@ public class ExceptionAdvice {
|
|||||||
return JsonResponse.error(e.getMessage());
|
return JsonResponse.error(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
|
||||||
|
public JsonResponse<String> httpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e){
|
||||||
|
return JsonResponse.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
|
||||||
public JsonResponse<String> unsupportedMediaTypeException(Exception e) {
|
public JsonResponse<String> unsupportedMediaTypeException(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
Reference in New Issue
Block a user