I
I
Igor Ponomarev2015-02-11 18:43:38
Java
Igor Ponomarev, 2015-02-11 18:43:38

How to properly configure the server to correctly display the downloaded file with the name in Cyrillic?

Good day to all!
There is a TomCat 7 server, I make it possible to download a file from the server;
The link to download the file looks like this:

<a href="downloadAction.action?struts.enableJSONValidation=true&fileName=тестовый файл.jpeg&fileId=2&fileContentType=null" target="_blank">тестовый файл.jpeg</a>

The encoding for the server, Java project, and generally wherever possible is UTF-8.
When you try to save the file, the browser loses Russian characters.
At the same time, if in the server.xml file from the line
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

Remove the encoding (URIEncoding="UTF-8"), then the names of downloaded files are displayed correctly, but a lot of things stop working.
If I try to send a name from the server via URLEncoder,
and in the struts settings I prescribe
filename*="utf8'ru-ru'${fileName}",
then everything works fine in fireFox, but Chrome names the file "downloadAction", the class that we call through the link.
Using links like .../fileName is extremely inconvenient due to struts.
Tell me, please, how to get out of the situation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alex stephen, 2015-02-11
@berezuev

Maybe you should decide on the client side?
davidwalsh.name/download-attribute

<a href="downloadAction.action?struts.enableJSONValidation=true&fileName=тестовый файл.jpeg&fileId=2&fileContentType=null" target="_blank" download="тестовый файл.jpeg">тестовый файл.jpeg</a>

I
Igor Ponomarev, 2015-02-12
@Eques_Pauperem

As a result, I did this:
I send the name from the server through URLEncoder, added the parameter to struts filename*="utf8'ru-ru'${fileName}".
So FireFox understands the name normally.
More via attribute

download
I specify the file name in the link, as Chrome understands.
One problem remains: IE...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question