The solution to the problem of garbled characters in the front-end of the SSM framework

1. Configure the filter in the web.xml file and add the following code:

<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. The JSP page needs to write the encoding format in the form of utf-8

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>

3. Add URIEncoding="UTF-8" to tomcat:

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>

This file is in the server.xml document in the Servers directory.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325853589&siteId=291194637