This content has been marked as final.
Show 3 replies
-
1. Re: MySQL encoding
cash1981 Apr 7, 2010 1:36 PM (in response to damnh.damnh.aureole-net.com.vn)Is the database the same or do you have two versions (one running on windows and one on linux)
I can't say I have seen the same problems. All I can say, is that you should ensure your database truly is utf8.
Just to be safe do the following:
mysql> set charset utf8; Query OK, 0 rows affected (0.00 sec) mysql> create database mydb default charset utf8; Query OK, 1 row affected (0.07 sec) show create database mydb; +----------+------------------------------------------------------------------+ | Database | Create Database | +----------+------------------------------------------------------------------+ | mydb | CREATE DATABASE mydb /*!40100 DEFAULT CHARACTER SET utf8 */ | +----------+------------------------------------------------------------------+
Ensure your tables are utf8;
mysql> show create table Role; | Role | CREATE TABLE Role ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(255) NOT NULL, PRIMARY KEY (id), UNIQUE KEY name (name) ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 |
Remember the UTF-8 on all xml files:
<?xml version="1.0" encoding="UTF-8"?>
If that doesn't help. Add these in components.xml
<!-- Below line actually desn't work because of bug in seam encoding filter The bug has been fixed by implementing UTF8Filter Anyway keep the line, it might be useful when upgrading seam version. --> <web:character-encoding-filter encoding="UTF-8" override-client="true" url-pattern="*.seam" />
Here is the UTF8Filter:
public class UTF8Filter implements Filter { public void destroy() {} public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { // set encoding to UTF-8 req.setCharacterEncoding("UTF-8"); chain.doFilter(req, res); return; } public void init(FilterConfig arg0) throws ServletException { // Nothing to do here } }
Remember to add the filter in web.xml
<filter> <filter-name>UTF8 Filter</filter-name> <filter-class>no.kommuneforlaget.fagsystem.saksapp.filter.UTF8Filter</filter-class> </filter> <filter-mapping> <filter-name>UTF8 Filter</filter-name> <url-pattern>*.seam</url-pattern> </filter-mapping>
This should do it!
-
2. Re: MySQL encoding
blabno Apr 7, 2010 4:56 PM (in response to damnh.damnh.aureole-net.com.vn)Maybe you should configure datasource?
Driver/Datasource Class Names, URL Syntax and Configuration Properties for Connector/J
Notice the
useUnicode
property. -
3. Re: MySQL encoding
damnh.damnh.aureole-net.com.vn Apr 8, 2010 4:57 PM (in response to damnh.damnh.aureole-net.com.vn)Thank you for your help!
My problem is solved. But the main cause is MySQL's file my.cnf which not configured utf8 on Centos. Anyway, thank you everybody!