String cl=new String(req.getParameter("checkboxvalue").getBytes("iso8859-1"),"gb2312");
excel
?Connection connection = DbConnectionManager.getConnection();
??????? try{
??????????
??????? ?
??????????? PreparedStatement prst = connection.prepareStatement(sql);
??????????? ResultSet rs = prst.executeQuery();
??????????? if(rs.next()){
??????????? ?//if(rs == null){rs.close();
??????????????? Blob blob = rs.getBlob("bb");
?????????????
??????????????? byte[] ab = blob.getBytes(1, (int)blob.length());
??????????????? //URLEncoder.encode(rname, "utf-8");
??????????????? //new String("文件名.xls".getBytes("GBK"),"ISO8859_1")
??????????????? //response.setHeader("Charset","gb2312");
??????????????? //application/msexcel-comma
??????????????? String fs = new String(rname.getBytes("GBK"),"ISO8859_1");
????????????????
??????????????? response.reset();
??????????????? response.setLocale(java.util.Locale.CHINA);
??????????????? response.setContentType("application/vnd.ms-excel");
??????????????? request.setCharacterEncoding("GBK");
??????????????
??????????????
??????????????? String s = "attachment; filename="+fs;
??????????????? response.setHeader("Content-Disposition", s);
??????????????? ServletOutputStream op = response.getOutputStream();
??????????????? op.write(ab);
??????????????? op.flush();
??????????????? op.close();
??????????? }
???????? }catch(SQLException e){
??????? log.info(e.toString()+"sql:"+sql);
???? }
???????? catch(NullPointerException ex){
??????? ? System.out.print("數據為空");
???????? }
????????
???????? finally{
???????? try{
???????? connection.close();
?????? }catch(Exception e){
???? ?? System.out.print("ddd");
?????? }