Determine browser type, Firefox browser do special processing, otherwise download file name garbledPublicStaticvoid Compatiblefilename (HttpServletRequest request, httpservletresponse response,String excelname) throws Unsupportedencodingexception {String Agent = Request.getheader ("User-agent"). toLowerCase (); Response.setcontenttype ("Application/vnd.ms-excel");String fileName = excelname;String codedfilename = Java.net.URLEncoder.encode (FileName,"UTF-8");if (Agent.contains ("Firefox") {response.setcharacterencoding ("Utf-8"); Response.setheader ( "Content-disposition", < Span class= "hljs-string" > "attachment;filename=" + new String ( Filename.getbytes (), "iso8859-1") + else {response.setheader ( "Content-disposition", < Span class= "hljs-string" > "attachment;filename=" + codedFileName + ". xls");}
Poi export Excel name garbled (valid for Ie,chrome,firefox)