我有一个Spring MVC bean,我想通过设置UTF-8编码来恢复土耳其语.但是虽然我的字符串是"şŞğĞİıçÇöÖüÜ"但它返回"??????çÇöÖüÜ".而且当我查看响应页面,即Internet Explorer页面时,编码是西欧iso,而不是UTF-8.
这是代码:
@RequestMapping(method=RequestMethod.GET,value="/GetMyList")
public @ResponseBody String getMyList(HttpServletRequest request, HttpServletResponse response) throws CryptoException{
String contentType= "text/html;charset=UTF-8";
response.setContentType(contentType);
try {
request.setCharacterEncoding("utf-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
response.setCharacterEncoding("utf-8");
String str="??????çÇöÖüÜ";
return str;
}
Run Code Online (Sandbox Code Playgroud)