Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Liferay 如何将querystring参数传递到登录页面?_Liferay_Liferay 6 - Fatal编程技术网

Liferay 如何将querystring参数传递到登录页面?

Liferay 如何将querystring参数传递到登录页面?,liferay,liferay-6,Liferay,Liferay 6,我们正在使用Liferay的自动登录,我需要将querystring参数传递到登录页面。例如,我需要能够访问foo的值: http://mysite.com/guest/group?foo=bar 你知道我该怎么做吗,因为在重定向到登录页面的过程中,默认情况下它会丢失查询字符串:( 谢谢!您将从原始HttpRequest获得相同的结果 请使用com.liferay.portal.util.PortalUtil类。其中有两个方法。因此,首先,通过传递portletRequest获取httpReq

我们正在使用Liferay的自动登录,我需要将querystring参数传递到登录页面。例如,我需要能够访问foo的值:

http://mysite.com/guest/group?foo=bar
你知道我该怎么做吗,因为在重定向到登录页面的过程中,默认情况下它会丢失查询字符串:(


谢谢!

您将从原始HttpRequest获得相同的结果

请使用
com.liferay.portal.util.PortalUtil
类。其中有两个方法。因此,首先,通过传递
portletRequest
获取httpRequest(),然后通过
getOriginalServletRequest()获取原始http请求
通过传递从
getHttpServletRequest()
获得的httpRequest


根据该请求,尝试搜索参数
foo

,您可以使用以下代码:

Object outcome = null;
Map<String, Object> map = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if (map != null) {
  for (String key : map.keySet()) {
    if (map.get(key) instanceof HttpServletRequestWrapper) {
      HttpServletRequest request = (HttpServletRequest) ((HttpServletRequestWrapper) map.get(key)).getRequest();
      outcome = request.getParameter("foo");
      break;
    }
  }
}
对象结果=null;
Map Map=FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if(map!=null){
for(字符串键:map.keySet()){
if(HttpServletRequestWrapper的map.get(key)instanceof){
HttpServletRequest=(HttpServletRequest)((HttpServletRequestWrapper)map.get(key)).getRequest();
结果=request.getParameter(“foo”);
打破
}
}
}

我在我的bean构造函数中有它。

好的,我对java portal开发没有经验,我想这是我可以在Liferay钩子中做的事情吗?你可以用一个片段或示例进一步帮助我吗?在login.events.pre-event上用钩子很好地破解了钩子,但没有运气:
http://localhost:8080/web/guest/welcome?foo=bar
公共类登录动作扩展动作{public void run(HttpServletRequest req,HttpServletResponse res){HttpServletRequest originalRequest=PortalUtil.getOriginalServletRequest(req);String origUrl=HttpUtil.getCompleteURL(originalRequest);String foo=HttpUtil.getParameter(origUrl,“foo”);System.out.println(“##origUrl:+origUrl”);System.out.println(“##foo:+foo);}
输出:##原图:http://localhost:8080/c ##foo:
只需尝试创建登录服务操作前钩子,在您将获得请求的情况下,尝试从那里获取参数,查看是否成功,如果您想在成功登录后获取参数,则必须使用登录操作后钩子。如上所述,没有运气返回空值: