There is a jsp file with the form: <% @ page contentType = "text / html" pageEncoding = "UTF-8"%> ... ... ...

The jsp file is UTF-8 encoded.

When submit arrives broken text - krakozaby.

  1. As the text "title" the following crap is displayed: "shouting around" In the browser, utf-8 is displayed.
  2. I use h2 db, there like utf by default.
  3. Converter correctly decodes using ISO-8859-5 encoding
  4. "Set URIEncoding =" UTF-8 "on your in server.xml." - did it, does not help.
  5. All sources: https://github.com/AndrewBryukhov/ClassicWebApplication page edit.jsp
  6. Observed under opera & ie & firefox
  7. Under the debugger, I see that the curved data comes from the browser.

I had to make a temporary fix, but I don't like it, because does not solve the cause: byte [] isoBytes = author.getBytes ("ISO-8859-1"); author = new String (isoBytes, "UTF-8"); Another strange moment found. If an error occurs on the server, tomcat gives out my jsp with corrupted Cyrillic texts, although the page is displayed in utf8. When decoding them, the converter says that it is utf8.

Adding to ConfigurationAdapter: @Bean public FilterRegistrationBean filterRegistrationBean () {CharacterEncodingFilter filter = new CharacterEncodingFilter (); filter.setEncoding ("UTF-8");

FilterRegistrationBean registrationBean = new FilterRegistrationBean(); registrationBean.setFilter(filter); registrationBean.addUrlPatterns("/*"); return registrationBean; } 

did not help ((

The problem is not in the database. crooked data come from the browser. Apparently it's in jsp or tomcat. So the question is relevant.

    1 answer 1

    I advise you to use utf-8 everywhere and write to begin with in web.xml:

     <filter> <filter-name>encoding-filter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encoding-filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 

    If it does not help add a recipe: http://elwood.su/2012/08/spring-responsebody-%D0%B8-utf-8/