Hello! Faced a problem, searches did not lead to anything. I process sql errors from the database in my controllers and send them to the front:
@ExceptionHandler(DataException.class) @ResponseBody public ResponseEntity<String> handleException(DataException e, HttpServletResponse response) { log.error(e); response.setContentType("application/json;charset=UTF-8"); response.setHeader("Content-Type", "application/json; charset=utf-8"); response.setCharacterEncoding("UTF-8"); if (e.getRootCause() instanceof SQLException) { SQLException s = (SQLException) e.getRootCause(); // return CommonUtil.getErrorResponse(ErrorToResponse.getJsonSqlError(s.getMessage(), s.getSQLState())); return new ResponseEntity<String>("ТУТ РУССКИЙ ЯЗЫК!", HttpStatus.INTERNAL_SERVER_ERROR); } else { log.error(e); return CommonUtil.getErrorResponse(ErrorToResponse.getJsonError(e.getMessage())); } } <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <array> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg index="0" name="defaultCharset" value="UTF-8"/> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>application/x-www-form-urlencoded;charset=UTF-8</value> </list> </property> </bean> </bean> <bean class="org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver"> <property name="messageConverters"> <array> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg index="0" name="defaultCharset" value="UTF-8"/> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>application/x-www-form-urlencoded;charset=UTF-8</value> </list> </property> </bean> </array> </property> </bean> But nothing helps! By the way in:
@RequestMapping(value = "/Services/getData", method = RequestMethod.POST) @ResponseStatus(HttpStatus.OK) public ResponseEntity<String> getData(@RequestParam(value = "param", required = true) String param, HttpServletRequest request, HttpSession httpSession) { return execute(param, request, httpSession, CRUDServiceDAO.Action.GET); } Russian comes without problems, the problem only occurs in @ExceptionHandler (DataException.class) I really hope for your help !!!