GSON not sending in UTF-8

前端 未结 3 740
心在旅途
心在旅途 2021-02-08 17:10

The following method sends a JSON reply. However on the receiving end I keep getting invalid characters, and UTF-8 isn\'t decoding the data. What am I doing wrong?

3条回答
  •  面向向阳花
    2021-02-08 18:08

    Use the following code to encode

     response.setCharacterEncoding("UTF8"); // this line solves the problem
     response.setContentType("application/json");
    

提交回复
热议问题