Strage character encoding problem with Eclipse / Spring / Tomcat 6

Posted by Czar on Stack Overflow See other posts from Stack Overflow or by Czar
Published on 2011-01-04T16:27:00Z Indexed on 2011/01/04 16:54 UTC
Read the original article Hit count: 373

Filed under:
|
|
|
|

Hi, I have been trying things all da but can't get a proper solution. My problem is: I am developing a Spring MVC based app in my local Tomcat. My MYSQl database has UTF-8 encoding set, all content in there displays properly when using phpMyAdmin. Also the output in LOG files using log4j in catalina.out works fine.

My JSP pages are configured by

<!-- encoding -->
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>

Also showing data on my JSP works fine. I can also send data from my Controller without any DB intereference using special chars, e.g.

String str = "UTF-8 Test: Ä Ö Ü ß è é â";
logger.debug(str);
mav.addObject("utftest", str);

That displays correctly in log and on jsp page in browser.

BUT: When having special chars directly in my JSP file, e.g. for text in headers, this does not work. FF and Google Chrome display strange chars but report the page to be UTF-8. When switching to Latin, the chars just get more and more strange.

Same problem when showing text tokens from my messages.properties file, although Eclipse says when right-clicking that UTF-8 will be used.

I am a little it lost and don't know where to check now.

Summary:

  • DB storage is fine
  • DB output on JSP is fine
  • Output on JSP directly form controller is fine
  • even reading in form forms is fine
  • .properties files and JSP text is not fine !!!

Any ideas? I really appreciate and tips.

© Stack Overflow or respective owner

Related posts about java

Related posts about spring