Spring MVC 异常响应编码设置 发表于 2016-12-30 | 分类于 Java 直接代码说话 1234567@ExceptionHandler(HumanReadableException.class)public ResponseEntity<String> handleHumanReadableException(Exception e) { logger.error("请求处理出错", e); HttpHeaders headers = new HttpHeaders(); headers.setContentType(new MediaType("text", "plain", Charset.forName("UTF-8"))); return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.INTERNAL_SERVER_ERROR);}