If you do not use Mysql, but HSqlDB, which is sent by default, you will not see your encoding problems. Problems arise due to Mysql, InnoDB and UTF-8.
Since you are using a Mysql connection and have already configured
useUnicode=true&characterEncoding=UTF-8to MySql connection url
you still have to add special hibernation dialogs for InnoDB and UTF-8:
Datasource.groovy must contain:
environments {
development {
dataSource {
......
driverClassName = "com.mysql.jdbc.Driver"
dialect = "com.domain.mysql.dialect.MySQLUTF8InnoDBDialect"
.....
Create a new file in src/java/com/domain/mysql/dialect/MySQLUTF8InnoDBDialect.java
package com.domain.mysql.dialect;
import org.hibernate.dialect.MySQLInnoDBDialect;
public class MySQLUTF8InnoDBDialect extends MySQLInnoDBDialect {
@Override
public String getTableTypeString() {
return " ENGINE=InnoDB DEFAULT CHARSET=utf8";
}
}
Make sure yours Config.groovyhas:
grails.views.default.codec = "html"
grails.views.gsp.encoding = "UTF-8"
grails.converters.encoding = "UTF-8"
And your views / layouts / main.gsp start with:
<%@ page contentType="text/html;charset=UTF-8" %>
hello
Jan