相关疑难解决方法(0)

Grails 没有正确编码 unicode 字符

在我的 grails 应用程序中,unicode 字符没有正确编码。

我正在使用 grails 1.3.7 和 tomcat 7.0.22。以下是我在我的应用程序中为 unicode 支持配置的设置:

- Set grails.views.gsp.encoding and grails.converters.encoding="UTF-8" in Config.groovy
- Set encoding to UTF-8 in meta tag in the .gsp pages
- Specified 'useUnicode=true&characterEncoding=UTF-8' to the MySql connection URL (DB has characterset set to UTF-8)
- Set URIEncoding="UTF-8" useBodyEncodingForURI="true" to the server.xml file in tomcat
- Specified the attribute accept-charset="UTF-8" of the form tag.
Run Code Online (Sandbox Code Playgroud)

但是,当我提交一个 unicode 字符时,grails 不支持该字符并且正在保存乱码值。我已经用谷歌搜索并阅读了 ppl 在同一问题上寻求帮助,但不幸的是,这些解决方案对我不利。尽管如此,我已经找到了解决此问题的方法。下面的表达式

params.detail = params.detail ? new String(params.detail.getBytes("8859_1"), "UTF8") : null
Run Code Online (Sandbox Code Playgroud)

将正确编码 …

unicode grails

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

grails ×1

unicode ×1