jsp 导出成CSV文件,中文乱码问题!
格式是UTF-8,
用editplus打開正常,但是excel打開就是亂碼了!!
怎么解決?
os = response.getOutputStream(); String title = "發送編號,時間,標題,接收號碼,訊息編號,接收時間,接收狀態"+"\r\n"; os.write(title.getBytes("UTF-8")); QueryBean qb = (QueryBean) request .getAttribute(GlobalConstNaming.QUERY_BEAN_NAME); ResultBean resultBean = null; resultBean=statReportMag.thrdinfo(qb,jobid,date); List result = (List)resultBean.getTotalResult(); for(int i=0;i<result.size();i++) { StatSendthrdbean bean = (StatSendthrdbean)result.get(i); String s = bean.getJobid(); s = s + ","; s = s + bean.getDate(); s = s + ","; s = s + (bean.getContent()==null?" ":bean.getContent()); s = s + ","; s = s + (bean.getRecvmobile()==null? " " : bean.getRecvmobile()); s = s + ","; s = s + (bean.getMsgid()==null ? " " : bean.getMsgid()); s = s + ","; s = s + (bean.getRecvdate()==null? " " : bean.getRecvdate()); s = s + ","; s = s + (bean.getStatus()==null ? " " : bean.getStatus()); s = s + "\r\n"; os.write(s.getBytes("UTF-8")); }