I try to deploy a Spring project on the openshift service. I'm trying to write to the database in utf-8 encoding. However, Russian letters fall into the database table in the following form:
ÑÑмÑÑмÑÑм That is, in ISO 8859-1 (latin-1).
in the URL by which Hibernate is connected to the database, I specify the UTF-8 encoding:
jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/jbossews?useUnicode=yes&characterEncoding=UTF-8 I specify utf-8 in JSP
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %> <form action="addMessage" method="get" accept-charset="utf-8"> <textarea maxlength="600" name="message"></textarea><br/> <input type="submit" id="button" value="отправить сообщение"/> </form> I create base with such command:
create database jbossews default character set = "UTF8" default collate = "utf8_general_ci" Such a filter in web.xml does not bring any results:
filter> <filter-name>encoding-filter</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>encoding-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> It is not possible to change some settings in the my.conf file. Mysql, because changes to this file are reset after restarting the database. Here is the database itself:
mysql> SHOW VARIABLES LIKE'character%'; Variable_name Value character_set_client utf8 character_set_connection utf8 character_set_database latin1 character_set_filesystem binary character_set_results utf8 character_set_server latin1 character_set_system utf8 character_sets_dir /opt/rh/mysql55/root/usr/share/mysql/charsets/ SHOW VARIABLES LIKE 'collation%'; Variable_name Value collation_connection utf8_general_ci collation_database latin1_swedish_ci collation_server latin1_swedish_ci Help solve the problem with writing in the wrong encoding.
jbossewsCHARACTER SET utf8 COLLATE utf8_general_ci;' in hibernet settings: '# db.url =. .. jbossews? useUnicode = yes & characterEncoding = UTF-8 'in the title of the page: contentType = "text / html; charset = UTF-8" Everywhere, like, set utf-8 and still a coding error. It is in the table that the records are stored in the wrong encoding. If you make an entry directly in phpMyAdmin in Russian letters in the table, it is correctly displayed in the table and on the page. And when the application makes an entry in the database, it turns out kozyabry. - fantastic