utf-8网址问题 [英] utf-8 url problem

查看:87
本文介绍了utf-8网址问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行的tomcat(7)服务器,我尝试通过该服务器访问http的一些公共文件.文件系统上的某些文件中包含特殊字符.找到那些没有那些特殊字符的字符.其他的则给出404.例如:

http://localhost:9090/processed/transcoded /Csángó_TÖMEGKERESZTELŐVEL_EGYBEKÖTÖTT_búcsú_Istensegítsfalvámp20111053491309424029417_ed.

从我发现url中的utf-8应该不是问题.我尝试对文件名使用url逃逸功能,结果是:

解决方案

<Connector中是否有URIEncoding="UTF-8"?如果是的话,这就是我要做的:

  1. 创建一个测试Web应用程序,该应用程序的过滤器可拦截对/processed/transcoded/*
  2. 的所有调用
  3. 在该过滤器上放置一个断点,看看会得到什么.解码时文件名有意义吗?
  4. 尝试使用此路径打开新的java.io.File(显然在本地位置之前,例如/home/someuser/files/...并假设文件在其中).

我认为tomcat的功能不比上面列出的要多.

另一种选择是调试Tomcat本身.

I have a tomcat (7) server running, through which I try to access some public files by http. Some of the files on the filesystem have special characters in them. The ones without those special characters are found. The other ones give a 404. For example:

http://localhost:9090/processed/transcoded/Csángó_TÖMEGKERESZTELŐVEL_EGYBEKÖTÖTT_búcsú_Istensegítsfalvá20111053491309424029417_extracted.mp3"

From what I found out utf-8 in urls shouldn't be a problem. I've tried an url escape function on the filename, which resulted in:

http://localhost:9090/processed/transcoded/Cs%c3%a1ng%c3%b3_T%c3%96MEGKERESZTEL%c5%90VEL_EGYBEK%c3%96T%c3%96TT_b%c3%bacs%c3%ba_Istenseg%c3%adtsfalv%c3%a120111053491309424029417_extracted%2emp3

... but that didn't seem to solve anything either. What to try next? I have no clue what the problem is. Is it maybe related to a Tomcat settings?

解决方案

Do you have URIEncoding="UTF-8" in your <Connector? If yes, here's what I would do:

  1. create a test webapp which has a filter intercepting all calls to /processed/transcoded/*
  2. place a breakpoint on that filter and see what you get. Does the file name make sense when decoded?
  3. try to open a new java.io.File using this path (obviously prepending local location, e.g. /home/someuser/files/... and assuming the file is there).

I don't think tomcat does much more than what is listed above.

Another alternative would be to debug the Tomcat itself.

这篇关于utf-8网址问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆