How to solve the garbled file name when downloading in Firefox browser

String agent = request.getHeader("user-agent");
response.setContentType("application/x-download");
if(agent.contains("Firefox"))
    response.addHeader("Content-Disposition","attachment ;filename="+ new String(displayFileName.getBytes("GB2312"),"ISO-8859-1"));
else
    response.addHeader("Content-Disposition","attachment;filename=" + URLEncoder.encode(displayFileName , "UTF-8"));

I also encountered this problem just now. Based on the above answers, I will post my approach. It is no problem to test in IE, Google, Firefox and other browsers!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326192102&siteId=291194637