Преглед на файлове

response编码设置utf-8

xiatian преди 3 години
родител
ревизия
bf9e1a5a88
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      examcloud-web/src/main/java/cn/com/qmth/examcloud/web/support/CustomExceptionHandler.java

+ 4 - 2
examcloud-web/src/main/java/cn/com/qmth/examcloud/web/support/CustomExceptionHandler.java

@@ -10,6 +10,7 @@ import cn.com.qmth.examcloud.web.jpa.DataIntegrityViolationTransverter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.dao.DataIntegrityViolationException;
+import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.converter.HttpMessageNotReadableException;
@@ -245,8 +246,9 @@ public class CustomExceptionHandler {
                 LOG.debug(err.getMessage(), err);
             }
         }
-
-        return new ResponseEntity<>(body, httpStatus);
+        HttpHeaders headers = new HttpHeaders();
+        headers.add("Content-Type","application/json;charset=utf-8");
+        return new ResponseEntity<>(body, headers,httpStatus);
     }
 
     /**