前端代码://通过ajax传递值,出现返回值中文乱码问题$.ajax({ url:‘buyerCartMoreHandle‘, type:‘post‘, contentType: "application/x-www-form-urlencoded; charset=utf-8", data:param, dataType:‘text‘, success:function(data){ alert(data); window.location.reload(); } })
后端代码
@RequestMapping(value="buyerCartMoreHandle",method=RequestMethod.POST,produces={"text/html;charset=UTF-8;","application/json;"}) @ResponseBody public String buyerCartMoreHandle(Model m,@RequestParam(value = "buyerCartArray[]") String[] buyerCartArray) //通过更改参数类型的形式传递数组,@requestParam(value="") //返回值则是通过在requestm中的 produces={"text/html;charset=UTF-8;","application/json;"} 实现 }
详情参考:
https://www.cnblogs.com/zique/p/6171862.html
原文地址:https://www.cnblogs.com/li-yi-learn/p/9057593.html
时间: 2024-12-17 22:02:49