Simply putted I can't download files that are hosted in my web server if they have special characters in the filename because I get 404.
If I create a file called olá.txt I don't seem to find the correct URL to download it. I've tried all possible ways to download it:
mydomain.com/olá.txt
mydomain.com/ol%C3%A1.txt
and I always get a 404 from Apache Tomcat 7.0.3, but if I change the file name to ola.txt everything is fine.
I've added AddDefaultCharset utf-8
to the httpd.conf but I still have the issue.
I mean it should be possible to download files with names containing non ascii characters, right?
Update: My server.xml
has:
<Connector URIEncoding="UTF-8" compressableMimeType="text/javascript,text/css"
compression="on" compressionMinSize="2048" connectionTimeout="20000"
noCompressionUserAgents="gozilla, travista" port="8080"
protocol="HTTP/1.1" redirectPort="8443"/>
Update:
echo -n olá | od -An -tx1 = 6f 6c c3 a1
echo $LANG = en_US.UTF-8
locale:
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
You might need to add this to the <connector ... />
tag in your server.xml for Tomcat:
URIEncoding="UTF-8"
More info:
How to get UTF-8 working in Java webapps?
utf-8 url problem
I've bee having trouble reproducing this on my end. I've done a clean install of Tomcat 7.0.26 on Ubuntu 12.04.4 LTS, created /var/lib/tomcat7/webapps/ROOT/testé.txt
, and successfully served that file to my browser at the url http://localhost:8080/testé.txt
.
This is my connector tag in /etc/tomcat7/server.xml
:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
I can't say why yours isn't working, at this time, but I can at least confirm that serving UTF-8 encoded files with tomcat7 is possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With