Spring MVC + Hibernate encoding problem
- by Bar
I work on Spring MVC + Hibernate application, use MySQL (ver. 5.0.51a) with the InnoDB engine.
The problem appears when I am sending a form with cyrillic characters.
As the result, database contains senseless chars in unknown encoding.
All the JSP pages, database (+ tables and fields) created using UTF-8.
Hibernate config also contains property which sets encoding to UTF-8.
I had solved this by creating filter which encodes request content with UTF-8.
Exemplary code:
…
encoding = "UTF-8";
request.setCharacterEncoding(encoding);
chain.doFilter(request, response);
…
But it visibly slows down the app.
The interesting thing is that executing insert query directly from the app (i.e. running from Eclipse as Java Application) works perfect.
Any suggestions are welcome.
TIA,
Michael.