UTF-8 encoding with form post and Spring Controller

前端 未结 3 1747
轮回少年
轮回少年 2021-01-11 21:13

I am trying to submit a form, which has UTF8 characters inside it. The form looks like this:

3条回答
  •  温柔的废话
    2021-01-11 21:55

    Looks like browsers don’t send the charset as part of Content-Type in request headers (even when accept-charset on form is set) and Tomcat deals with body of such requests as Latin-1 ( http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q1 ).

    So at a later point this might have been decoded as Latin-1 and encoded as UTF-8 resulting in garbled up characters.

    Moving CharacterEncodingFilter to the top and forcing the encoding to be set as UTF-8 solved the problem.

提交回复
热议问题