如何防止 Flash 的 URLRequest 转义 URL?
我从 Flex 应用程序的 servlet 加载一些 XML,如下所示:
_loader = new URLLoader();
_loader.load(new URLRequest(_servletURL+"?do=load&id="+_id));
正如您可以想象 _servletURL
类似于 http://foo.bar/path/to/servlet
在某些情况下,此 URL 包含重音字符(长话短说)。 我将 unescaped
字符串传递给 URLRequest
,但 flash 似乎对其进行了转义并调用了转义的 URL,这是无效的。 有想法吗?
I load some XML from a servlet from my Flex application like this:
_loader = new URLLoader();
_loader.load(new URLRequest(_servletURL+"?do=load&id="+_id));
As you can imagine _servletURL
is something like http://foo.bar/path/to/servlet
In some cases, this URL contains accented characters (long story). I pass the unescaped
string to URLRequest
, but it seems that flash escapes it and calls the escaped URL, which is invalid. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我的朋友路易斯想通了:
你应该使用encodeURI来进行UTF8URL编码
http://livedocs.adobe.com/flex/3/langref /package.html#encodeURI()
但不转义,因为它转义为 ASCII 看到
http://livedocs.adobe.com/flex/3/langref /package.html#unescape()
我认为这就是我们在 URL 中得到 %E9 而不是预期的 %C3%A9 的地方。
http://www.w3schools.com/TAGS/ref_urlencode.asp
My friend Luis figured it out:
You should use encodeURI does the UTF8URL encoding
http://livedocs.adobe.com/flex/3/langref/package.html#encodeURI()
but not unescape because it unescapes to ASCII see
http://livedocs.adobe.com/flex/3/langref/package.html#unescape()
I think that is where we are getting a %E9 in the URL instead of the expected %C3%A9.
http://www.w3schools.com/TAGS/ref_urlencode.asp
我不确定这是否会有所不同,但这是实现相同 URLRequest 的更简洁的方法:
I'm not sure if this will be any different, but this is a cleaner way of achieving the same URLRequest:
来自 livedocs: http://livedocs.adobe.com/ flex/3/langref/flash/net/URLRequest.html
此页面包含更多信息:http://livedocs。 adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_3.html
但基本上你只需要将其添加到将在 URLRequest 之前运行的函数中(我可能会将其放在creationComplete中)事件)
System.useCodePage = false
;From the livedocs: http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequest.html
This page has more information: http://livedocs.adobe.com/flex/3/html/help.html?content=18_Client_System_Environment_3.html
but basically you just need to add this to a function that will be run before the URLRequest (I would probably put it in a creationComplete event)
System.useCodePage = false
;