|
|
|
|
@ -18,9 +18,17 @@ public class HttpStatusCodeExceptionControllerAdvice extends ResponseEntityExcep
|
|
|
|
|
public ResponseEntity<Object> handleHttpStatusCodeException(
|
|
|
|
|
final HttpStatusCodeException exception, final WebRequest webRequest) {
|
|
|
|
|
int status = exception.getStatus();
|
|
|
|
|
boolean isJsonResp = exception.isJsonResp();
|
|
|
|
|
|
|
|
|
|
String body = exception.getMessage();
|
|
|
|
|
|
|
|
|
|
HttpHeaders header = new HttpHeaders();
|
|
|
|
|
header.setContentType(new MediaType(MediaType.TEXT_PLAIN, StandardCharsets.UTF_8));
|
|
|
|
|
if(isJsonResp) {
|
|
|
|
|
header.setContentType(new MediaType(MediaType.APPLICATION_JSON, StandardCharsets.UTF_8));
|
|
|
|
|
} else {
|
|
|
|
|
header.setContentType(new MediaType(MediaType.TEXT_PLAIN, StandardCharsets.UTF_8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return handleExceptionInternal(exception, body, header, HttpStatus.valueOf(status), webRequest);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|