私の grails アプリでは、Unicode 文字が正しくエンコードされていません。
grails 1.3.7 と tomcat 7.0.22 を使用しています。以下は、ユニコードをサポートするためにアプリで構成した設定です。
- 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.
それでも、Unicode 文字を送信すると、grails はその文字をサポートしておらず、文字化けした値が保存されています。私はグーグルで検索し、この同じ問題について助けを求めるpplを読みましたが、残念ながら解決策は私の好意では機能しません. ただし、この問題の回避策を見つけました。次の式
params.detail = params.detail ? new String(params.detail.getBytes("8859_1"), "UTF8") : null
Unicode 文字を正しくエンコードします。
ただし、アプリのすべてのテキスト入力に対してこれを行う必要があるため、このアプローチを使用するのは面倒です。grails や tomcat で Unicode 文字が正しくエンコードされないのはなぜですか? 私は正しい設定を持っていると思います。