springMVC returns json garbled problem

I have encountered this problem many times. The json string returned to the front end under springMVC is always garbled in Chinese. Every time I have to go through the previous code to see the solution, it is necessary to make a note to write down this problem.

 

Solution:

Add the following to the method annotation:

@RequestMapping(value = "/auditingSelector", produces = "application/json;charset=UTF-8")

 

Where application/json means return json format

  text/html means to return a string or web page content.

 

After adding this, there should be basically no garbled problem, which is based on the premise of configuring encoding filtering.

Guess you like

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