Solve java program inserting data into mysql Chinese garbled

1. First of all, make sure the encoding method from foreground to background

           That is, configure the character encoding filter in web.xml (this filter must be before all filters)

    <filter>
     <filter-name>characterEncoding</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>
    </filter>
    <filter-mapping>
     <filter-name>characterEncoding</filter-name>
     <url-pattern>/*</url-pattern>
    </filter-mapping>

       

 2. Modify the configuration file my.ini in
     the mysql installation directory and change the default-character-set=latnl latnl under [client] and [mysqld] to utf8

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326804051&siteId=291194637