处理Flex应用程序中的重定向URL? [英] Handling redirected URL within Flex app?

查看:226
本文介绍了处理Flex应用程序中的重定向URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个Flex客户端和一个使用Spring / Blazeds项目的服务器。

We have a Flex client and a server that is using the Spring/Blazeds project.

用户登录并进行身份验证后,spring安全层发送一个重定向到我们的主应用程序所在的新URL。

After the user logs in and is authenticated, the spring security layer sends a redirect to a new URL which is where our main application is located.

但是,在flex客户端中,我正在使用HTTPService作为初始请求,我得到了重定向页面完整地发回给我。

However, within the flex client, I'm currently using HTTPService for the initial request and I get the redirected page sent back to me in its entirety.

如何获取URL以便我可以使用navigatetourl来获取应用程序所需的位置?

How can I just get the URL so that I can use navigatetourl to get where the app to go where it needs to?

非常感谢任何帮助。谢谢!

Any help would greatly be appreciated. Thanks!

推荐答案

一种解决方案是在返回页面的注释块中包含一个令牌,例如:

One solution would be to include a token inside a comment block on the returned page, for instance:

<!-- redirectPage="http://localhost/new-location" -->

然后检查它是否存在于HTTPService结果处理程序中。然后可以在对navigateToURL的调用中使用令牌的值。

then check for it's presence inside the HTTPService result handler. The token's value could then be used in your call to navigateToURL.

另一种解决方案是检查HTTP响应头并使用ActionScript提取Location头的值。考虑使用AS3 HTTP客户端库。

Another solution would be to examine the HTTP response headers and extract the value of the "Location" header using ActionScript. Consider using the AS3 HTTP Client lib.

从示例页面 http://code.google.com/p/as3httpclientlib/wiki/Examples 要确定回复中的位置标题:

From the examples page http://code.google.com/p/as3httpclientlib/wiki/Examples To determine the 'Location' header from the response:

var client:HttpClient = new HttpClient();

var uri:URI = new URI("http://localhost/j_security_check");

client.listener.onStatus = function(event:HttpStatusEvent):void {
  var response:HttpResponse = event.response;
  // Headers are case insensitive

  var redirectLocation:String = response.header.getValue("Location");
  // call navigateToURL with redirectLocation
  // ... 
};

// include username and password in the request

client.post(uri);

注意:AS3 HTTP客户端依赖于AS3 Core和AS3 Crypto库。

NOTE: AS3 HTTP Client depends on AS3 Core and AS3 Crypto libs.

这篇关于处理Flex应用程序中的重定向URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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