Good day.
There is a simple CRUD application on Spring Boot.
In the IDE, everything works as it should, no problem.
Generated WAR, zadepil in TomCat - everything works there too, except for the encoding when sending data from the form - krakozyabry are written, i.e. instead of "test" in the database goes "Р Ð ÐµÑÑ". Google, but alas ...
In application.properties:
spring.mvc.view.prefix=/WEB-INF/jsp/ spring.mvc.view.suffix=.jsp spring.data.jpa.repositories.enabled=true spring.jpa.generate.ddl=true spring.jpa.hibernate.ddl-auto=create spring.jpa.show-sql=true spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=root spring.datasource.sqlScriptEncoding=UTF-8 spring.messages.encoding=UTF-8 server.tomcat.uri-encoding=UTF-8 spring.http.encoding.charset=UTF-8 In pom.xml there is:
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> In web.xml there is:
<filter> <filter-name>characterEncodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app> In Application.java there are:
@Bean public FilterRegistrationBean filterRegistrationBean() { FilterRegistrationBean registrationBean = new FilterRegistrationBean(); CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); characterEncodingFilter.setForceEncoding(true); characterEncodingFilter.setEncoding("UTF-8"); registrationBean.setFilter(characterEncodingFilter); return registrationBean; } In .jsp are present:
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> and
<meta charset="utf-8"> What else did I miss?
Update: A shortened working project http://web-site.ru/Library.rar
schemain the database should be created with theutf8_general_cicoding, and not by default inlatin1, check this encoding. - MrFylypenkoТеÑÑasыцее, and the original encoding iscp866. By default, the windowscp866console and there is no utf8 support, there are suspicions that through it and see. Add information where you start the project (locally, remotely, which axis), how and through what you look at the logs. And ideally, lay out a minimal reproducible example on a githab, or in a question. - MrFylypenko