中文解码以及编码

2019-04-14 15:51发布

URLEncoder.encode(mes); mes=new String(mes.getBytes("iso8859-1"),"utf-8"); request.setCharacterEncoding("utf-8");
response.setContentType("application/text; charset=utf-8");
设置工作空间字符集的utf-8:windows---preferences---myeclipse---files and editors---jsp---utf-8 设置文件字符集的utf-8:文件---preferences---java build path---libraries---add library---jre system library

解码: System.out.println(new String(responseStr.getBytes("iso8859-1"),"GBK")); msg = new String(msg.getBytes("UTF-8"), "UTF-8"); respDesc=new String(respDesc.getBytes("iso8859-1"),"utf-8"); System.out.println(new String(URLDecoder.decode(desc).getBytes("ISO-8859-1"),"utf-8"));