From 06a7e45b5c6108f8e76a61b594b154d8890e3084 Mon Sep 17 00:00:00 2001 From: qxo Date: Sat, 20 Apr 2019 09:58:30 +0800 Subject: [PATCH] Default html Content-Type should with UTF-8 change Whitelabel Error Page Content-Type to "text/html;charset=UTF-8" or change AbstractErrorWebExceptionHandler.renderDefaultErrorView html content with `` --- .../web/reactive/error/DefaultErrorWebExceptionHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java index 568e08b84e43..1171f94a105e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandler.java @@ -105,6 +105,8 @@ protected RouterFunction getRoutingFunction( this::renderErrorResponse); } + private static final MediaType HTML_CONTENT_TYPE = MediaType.valueOf(MediaType.TEXT_HTML_VALUE+";charset=UTF-8"); + /** * Render the error information as an HTML view. * @param request the current request @@ -115,7 +117,7 @@ protected Mono renderErrorView(ServerRequest request) { Map error = getErrorAttributes(request, includeStackTrace); HttpStatus errorStatus = getHttpStatus(error); ServerResponse.BodyBuilder responseBody = ServerResponse.status(errorStatus) - .contentType(MediaType.TEXT_HTML); + .contentType(HTML_CONTENT_TYPE); return Flux .just("error/" + errorStatus.value(), "error/" + SERIES_VIEWS.get(errorStatus.series()), "error/error")