解决方案
一、使用produces属性 设置返回的内容的类型以及字符集
@RequestMapping(value = "/itemcat/list",
produces=MediaType.APPLICATION_JSON_VALUE+";charset=utf-8")
@ResponseBody
public String getItemCatList(String callback){
CatResult itemCatList = itemCatService.getItemCatList();
String json = JsonUtils.objectToJson(itemCatList);
String resultJson = callback+"("+json+");";
//System.out.println(json);
return resultJson;
}
二、使用MappingJacksonValue 解决,需要在spring4.1 版本以上才行
@RequestMapping(value = "/itemcat/list")
@ResponseBody
public Object getItemCatList(String callback){
CatResult itemCatList = itemCatService.getItemCatList();
MappingJacksonValue jacksonValue = new MappingJacksonValue(itemCatList);
jacksonValue.setJsonpFunction(callback);
return jacksonValue;
}