internet explorer - Can't download attachment in IE8(Javamail) -


I can not download attachments from email to IE nothing happened But my code works in Chrome, here is the code download:

  public string downloadcat () {inputstream atstream = empty; OutputStream Ostream = Faucet; Try {string mailid = getRequest () GetParameter ("mailid"); String filename = getRequest () GetParameter ("filename"); Mailbox all = new mailbox serivum (); CmMailbox mailbox = all .gate mailbox (mailed); If (mailbox! = Null & mailbox .getCmessageBody ()! = Null) {session session = session .get instances (System.getProperties (), blank); InputStream iStream = Mailbox .getCmessageBody () .getBinaryStream (); MimeMessage Message = New MimeMessage (session, iStream); Mailmanage mm = new mailmanage (); AttStream = mm.getAttach (message, file name); If (atstream! = Blank) {getResponse () SetContentType ("Application / OCitT-Stream"); // ("App / X-MS Downgrade"); GetResponse () setContentLength (attStream.available ()). GetResponse () setHeader ("Content-configuration", "attachment; file name = \" "+ URLEncoder.encode (filename," UTF-8 ") +" \ ""); Byte [] Chef = new byte [2048]; Ostream = getResponse () GetOutputStream (); Int count = 0; While ((calculation = eststream.rade (buff, 0, 1024)) gt; {ostream.write (buff, 0, count);} OStream.flush (); oStream.close (); attStream.close (); ostream = Null;}} Else {writeMsg (wrong, "a ?? ½½½é ???? ä» ¶å ?? ºé ???? i ¼ ?? é ??®a »¶ä¸ ?? a ?? Å ?? ¨ æ ?? e ¥ é ?? ®® »¶ ¶ ¶ ¶ ¶ æ æ æ æ æ æ æ æ æ æ æ æ æ æ æ      ä ä ä? ");}} Hold (exception e) {// TODO: exception handling handle. Panic (e.toString ()); writeMsg (wrong," a ?? ½½½ ???? ä »¶å ?? ºé ?? ?? I ¼ ?? é ???? è¯¯ï¼ ?? "+ e.getMessage ());} Finally {if (atstream! = Null) {try {attStream.close ();} hold (exception E2) {// TODO: handle exception}} if (ostream! = Null) {try {oStream.close ();} Exclamation E2} {// TODO: Exception exception}}} return tap;}   

jsp has a link to attachment:

  '? & Lt; a href = "downloadattachmail.action mailid =' + mailboxid + '& amp; file name =' + fname + '" target = "_ blank">' + fname + '& lt; / a & Nbsp; & amp; nbsp; & nbsp; '+ fsize   a new window 

with recently opened link links (ex: local host: 8081 / CMAIL / downloadattach Mail.action mailid = 40e4c0b6386e81e801386f0e67ce0018 & amp; File name = Java-event䏿 ???? Æ ???? Ä »¶.doc?), But nothing will happen. And the "save as" menu also can not work, is there something wrong? Thanks!

Download can work under Chrome, Firefox and IE 9. But it just can not work in IE8 (probably can not work in IE 7 and IE6)

I got the reason but it is very strange! To decode the Chinese character, I changed the tomatat configuration by adding:

  URI encoding = "UTF-8"   

If the name of the attachment is English , Do all the good work (Chrome, IE 8, IA 9, Firefox). But if the name is a Chinese character, then the parameter becomes messy while using ether 8, in the meanwhile everything is good in Chrome, Firefox and IE 9. I have changed Configure of Tomcat:

  URIEncoding = "GBK"   

Ie8 works well but Chrome can not do Firefox.

I found the solution and shared it for everyone:

1). Set the entire project in UTF-8, set JSP in UTF-8 too. 2). In JS, encode "encoder" to the URL. 3). And use request.getParameter () to get it. Thanks for your kindness!

ask us all the obvious questions ...

Is your downloadatch () method Is being called anytime?

If so, is it throwing any exception or finding any other errors?

If you use ASCII-only filenames, does not it matter?

Comments