Configuração no WEB XML:
<!-- filter enforcing charset UTF-8 - must be first filter in the chain! -->
<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>
ENCODE NO MYSQL:
CREATE DATABASE MINHADATABASE CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
# For each database:
ALTER DATABASE DATABASE_name CHARACTER SET = latin1 COLLATE = latin1_swedish_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET latin1 COLLATE latin1_swedish_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET latin1 COLLATE latin1_swedish_ci;
On Windows, MySQL programs read startup options from the following files, in the specified order (top items are used first).
File Name
|
Purpose
|
WINDIR\my.ini, WINDIR\my.cnf
|
Global options
|
C:\my.ini, C:\my.cnf
|
Global options
|
INSTALLDIR\my.ini, INSTALLDIR\my.cnf
|
Global options
|
defaults-extra-file
|
WINDIR represents the location of your Windows directory. This is commonly C:\WINDOWS. You can determine its exact location from the value of the WINDIR environment variable using the following command:
C:\> echo %WINDIR%
INSTALLDIR represents the MySQL installation directory. This is typically C:\PROGRAMDIR\MySQL\MySQL 5.5 Server where PROGRAMDIR represents the programs directory (usually Program Files on English-language versions of Windows), when MySQL 5.5 has been installed using the installation and configuration wizards. SeeSection 2.3.3, “Installing MySQL on Microsoft Windows Using MySQL Installer”.
Make sure to set the client and server character set as well. I have the following in my MySQL configuration file (/etc/my.cnf):
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
Nenhum comentário:
Postar um comentário