一 代码位置
https://github.com/cakin24/imooc-springboot-starter-master
二 开发语言字符编码
1 HTML字符编码(index.html)
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
2 freemark字符编码(index.htl)
<head lang="en">
<meta charset="UTF-8" />
<title></title>
</head>
3 HttpResponse字符编码(com/imooc/controller/interceptor/OneInterceptor.java)
public void returnErrorResponse(HttpServletResponse response, IMoocJSONResult result)
throws IOException, UnsupportedEncodingException {
OutputStream out=null;
try{
response.setCharacterEncoding("utf-8");
response.setContentType("text/json");
out = response.getOutputStream();
out.write(JsonUtils.objectToJson(result).getBytes("utf-8"));
out.flush();
} finally{
if(out!=null){
out.close();
}
}
}
4 返回内容字符编码设定方法(com/imooc/controller/interceptor/TwoInterceptor.java)
public void returnErrorResponse(HttpServletResponse response, IMoocJSONResult result) throws IOException, UnsupportedEncodingException {
OutputStream out=null;
try{
response.setCharacterEncoding("utf-8");
response.setContentType("text/json");
out = response.getOutputStream();
out.write(JsonUtils.objectToJson(result).getBytes("utf-8"));
out.flush();
} finally{
if(out!=null){
out.close();
}
}
}
三 开发环境字符编码
四 数据库编码设定