浏览器下载服务器上jpg等静态资源方法
/**
* 服务器下载静态文件
* @param request
* @param response
* @param filePath
* @param fileName
* @throws Exception
*/
public static void browserDownloadFile(HttpServletRequest request, HttpServletResponse response, String filePath, String fileName) throws Exception {
File downloadFile = new File(filePath, fileName);
if (!downloadFile.exists() || !downloadFile.isFile()) {
throw new Exception("文件不存在!");
}
String userAgent = request.getHeader("User-Agent").toLowerCase();
if (userAgent.indexOf("firefox") > -1) { //火狐浏览器
fileName = new String(fileName.getBytes("UTF-8"), "ISO-8859-1");
response.setHeader("content-disposition", String.format("attachment; filename=\"%s\"", fileName));
} else {
response.setHeader("content-disposition", "att