【问题标题】:How to call absoluteURL() when adding OpenID support to a Play Framework application?向 Play Framework 应用程序添加 OpenID 支持时如何调用 absoluteURL()?
【发布时间】:2012-07-01 20:18:19
【问题描述】:

我正在尝试使用the documentation page 上的示例代码向 Play Framework 应用程序添加 OpenID 登录支持:

Map<String, String> attributes = new HashMap<String, String>();
attributes.put("email", "http://schema.openid.net/contact/email");
OpenID.redirectURL(
  openid, 
  routes.Application.openIDCallback.absoluteURL(), 
  attributes
);

问题是当我使用这段代码时,我得到以下编译错误:

找不到符号 [符号:方法 absoluteURL()] [位置:类 play.api.mvc.Call]

确实,Call 类没有无参数的absoluteURL() 方法; Call#absoluteURL() 方法是:

absoluteURL(Http.Request 请求)

和:

absoluteURL(Http.Request 请求,布尔安全)

我需要使用什么Http.Request 实例? secure参数有什么意义?

【问题讨论】:

    标签: java openid playframework-2.0


    【解决方案1】:

    尝试当前请求:

    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("email", "http://schema.openid.net/contact/email");
    OpenID.redirectURL(
      openid, 
      routes.Application.openIDCallback.absoluteURL(request()), 
      attributes
    );
    

    【讨论】:

    • 这似乎有效。你知道为什么要传入当前请求吗?
    • 可能会将原始请求标头(接受、语言等)传递给最终请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-24
    • 1970-01-01
    • 2010-09-06
    • 1970-01-01
    相关资源
    最近更新 更多