java开发中中文编码问题

时间:2023-03-09 18:35:06
java开发中中文编码问题
//ajax以get方式提交,字符串中包含中文
//后台struts中对该string的set方法中
this.jsonString = new String(jsoString.getBytes("ISO8859-1")); //struts2框架文件下载时,文件名包含中文
http://blog.****.net/wojiaohuangyu/article/details/51539520 String userAgent = request.getHeader("User-Agent"); 
//针对IE或者以IE为内核的浏览器
if (userAgent.contains("MSIE")||userAgent.contains("Trident")) {
fileName = java.net.URLEncoder.encode(fileName, "UTF-8");
} else {
//非IE浏览器的处理:
fileName = new String(fileName.getBytes("UTF-8"),"ISO-8859-1");
}