后台返回前台为字符串乱码问题
/** * 根据商品分类的Id查询名称 * @ResponseBody进行数据解析时,如果解析的是对象(pojo/vo/List/Map..) * 默认格式都采用utf-8格式解析. * 如果解析的数据是String类型,则按照iso-8859-1格式进行解析. * public class StringHttpMessageConverter extends AbstractHttpMessageConverter<String> { public static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1"); public abstract class AbstractJackson2HttpMessageConverter extends AbstractHttpMessageConverter<Object> public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); * @param itemId * @return */ @RequestMapping(value="/cat/queryItemName",produces="text/html;charset=utf-8") @ResponseBody public String findItemCatNameById(String itemId,HttpServletResponse response){ //response.setContentType("text/html;charset=utf-8"); return itemService.findItemCatNameById(itemId); }