| |

VerySource

 Forgot password?
 Register
Search
Author: 烟花雪

Use struts to achieve download, the Chinese file name is garbled when downloading, I have tried encoding conversion, no

[Copy link]

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-12 18:15:01
| Show all posts
tellyouThank you very much, but I just tried your test code, the result is the same, UTF-8 is eight-bit, certainly not possible, I used several other methods, the output is correct, but the download is still Garbled:
<% @ page pageEncoding = "GBK" contentType = "application / octet-stream"%>
<% String filename = new String (("ahhh.jar"). GetBytes ("GB2312"), "GBK");%>
<%
response.setHeader ("Pragma", "No-cache");
response.setHeader ("Cache-Control", "no-cache");
response.setDateHeader ("Expires", 0);
response.setHeader ("Content-Disposition", "attachment; filename =\" "+ filename +"\"");%>
<% out.write (65); out.write (66);%>
<% out.flush ();%>
<% System.out.println (new java.util.Date () + "/" + filename);%>
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-5-3 16:30:01
| Show all posts
Keep focusing on the answer
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-5-10 11:00:01
| Show all posts
UTF-8 is mine, you have to change it to your own, the character encoding of your submission page (Content-Type: text / html; charset = this), which is request.getCharacterEncoding ()
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-19 11:00:01
| Show all posts
Follow the answer
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list