URL解码ä-> ã1⁄4 [英] URL decode ä -> ã1⁄4

查看:152
本文介绍了URL解码ä-> ã1⁄4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,从URL解码会引起一些重大问题.请求网址包含%C3%BC作为字母ü".解码服务器端现在应该将其解码为ü,但是它做到了:ü

I have the problem that the decoding from a URL causes some major problems. The request URL contains %C3%BC as the letter 'ü'. The decoding server side should now decode it as an ü, but it does this: ü

解码是这样完成的:

decoded = URLDecoder.decode(value, "UTF-8");

虽然value包含'%C3%BC'并且解码后现在应该包含'ü',但这就是问题所在.这是怎么了我在一个以上的应用程序中使用了这种方法,并且在所有其他情况下都能正常使用...

while value contains '%C3%BC' and decoded should now conatain 'ü', but that's where the problem is. What's going wrong here? I use this method in more than one application and it works fine in all other cases...

推荐答案

我没有足够的声誉来发表评论,因此我必须使其尽可能接近答案.

I don't have enough reputation yet to comment, so I'll have to make this as close to an answer as possible.

如果您正在使用servlet,并且从servlet上调用getParameter()获得了值",那么它已经被servlet容器解码(正确或错误). (Tomcat?)

If you're using a servlet, and "value" is something that you got from calling getParameter() on the servlet, then it has already been decoded (rightly or wrongly) by the servlet container. (Tomcat?)

同样,如果它是路径的一部分.假设百分比编码的字节为ISO-8859-1(这是Tomcat的默认设置),则您的servlet容器可能对其进行了解码.如果这是您正在使用的应用服务器,请参阅文档中Tomcat的server.xml文件中Connector元素的URIEncoding属性.如果将其设置为UTF-8,Tomcat将假定百分比编码的字节代表UTF-8文本.

Likewise if it's part of the path. Your servlet container probably decoded it assuming that the percent-encoded bytes were ISO-8859-1, which is the default setting for Tomcat. See the document for the URIEncoding attribute of the Connector element in Tomcat's server.xml file, if that's what appserver you're using. If you set it to UTF-8, Tomcat will assume that percent-encoded bytes represent UTF-8 text.

这篇关于URL解码ä-> ã1⁄4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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