Wednesday, December 14, 2011

Spring saved my day on an UTF-8 encoding problem

I'm working on Jasig CAS (an SSO server) and I had an issue with special chars. For example, it was impossible to log in with a password like &é"'(-.
  • I checked my jsp file :it was encoded in UTF-8
  • I checked the encoding directive (<%@ page contentType="text/html; charset=UTF-8" %>) : OK
The idea was to force the request encoding with something like :


But I was in Spring MVC and I didn't want an ugly hack. Fortunately, Spring saved my day with a builtin servlet filter to declare in the web.xml.




Unknown said...
This comment has been removed by the author.
Unknown said...

Its important to say that this filter must come before other filters (took me some time to figure this out)

simashree said...

Thanks for the great information in your blog Selenium Training in Chennai