Problems with unicode encoding in spring projects

I had a problem with the encoding of Unicode characters. I developed a simple web application with support for multiple languages​​, which is called internationalization or i18n. In this application, the data were saved in a database, and then re-shown. But I get exceptions on production and it was a unicode utf-8 character encoding problem.
By the way, my application was developed using spring and hibernate and jpa2. It was kind of a nightmare and I was getting the exceptions frequently and I was completely no where-zone. At least, after searching and using many sources, I found out the solutions.

So here is the solutions–

First you need add some extra parameter in your database url. For example–


Secondary you’ve to add a filter in your web.xml

















And finally you have to make sure you have added following line in your jsp pages

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

and finally follow the command in your terminal

You should now be logged into the MySQL prompt. Here type the following commands :

mysql> use user_db;

mysql> alter database user_db default character set utf8 collate utf8_unicode_ci;

Query OK, 1 row affected (0.00 sec)

This should have done it.

okay, that’s how I solved the issue.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s