The solution to the problem of downloading files in FF browser and IE
- 2020-04-01 02:09:09
- OfStack
The download has the following problems with the FF browser
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201308/201308051513122.gif? 201375151340 ">
But in other browsers (IE, Chrome...) This problem did not appear on
You need to write a Utitl class under management
< img SRC = "border = 0 / / files.jb51.net/file_images/article/201308/201308051513122.gif? 201375151340 ">
But in other browsers (IE, Chrome...) This problem did not appear on
You need to write a Utitl class under management
package com.sencloud.dh.core.utils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import javax.servlet.http.HttpServletRequest;
/**
* Encodes the Chinese file name for the file stream output download Block differences between browser versions
*
* @author xutianlong
* @version [ The version number , Feb 7, 2013]
* @see [ Related classes / methods ]
* @since [ product / The module version ]
*/
public class OfficeUtil
{
public static String encodeChineseDownloadFileName(HttpServletRequest request, String pFileName)
{
String agent = request.getHeader("USER-AGENT");
try
{
if (null != agent && -1 != agent.indexOf("MSIE"))
{
pFileName = URLEncoder.encode(pFileName, "utf-8");
}
else
{
pFileName = new String(pFileName.getBytes("utf-8"), "iso8859-1");
}
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
return pFileName;
}
}