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

查看:31
本文介绍了在 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 以便我可以使用导航图来获取应用程序需要去的地方?

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 核心和 AS3 加密库.

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

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

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