controller 基于字符串乱码问题解决

1.后台获取数据乱码问题
 String formDataStr = StringUtils.isEmpty(req.getParameter("formData"))?"":req.getParameter("formData");

  formDataStr=new String(formDataStr.getBytes("iso-8859-1"),"utf-8");
 

2.SpringMVC controller层 前台乱码问题
@RequestMapping(value = "/getPurchaseContractResult", produces ={"application/text;charset=UTF-8"})
@ResponseBody
	public String itemlList(HttpServletRequest req, Model model) throws ManagerException {
		String purchaseOrderNo = req.getParameter("purchaseOrderNo");
		Map<String, Object> _map = new HashMap<String, Object>();
		_map.put("purchaseOrderNo", purchaseOrderNo);
		PurchaseOrderDtl p = new PurchaseOrderDtl();
		p.setPurchaseOrderNo(purchaseOrderNo);
		List<PurchaseOrderDtlDto> purchaseOrderDtl = this.purchaseOrderDtlManager.findByNo(_map);
		return purchaseOrderDtlManager.changeToDatagridList(purchaseOrderDtl);
	}

你可能感兴趣的:(utf-8)