今天遇到一个中文乱码问题:在spring boot的框架中从数据库获取一个xml-string返回给前台,中文乱码。以下是解决办法:

response.setHeader("Content-type", "text/html;charset=UTF-8");  
String data = "中文字符";
OutputStream outputStream = response.getOutputStream();
outputStream.write(data.getBytes("UTF-8"));