本文介绍了PortalUtil.getOriginalServletRequest和PortalUtil.getHttpServletRequest有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想知道

PortalUtil.getOriginalServletRequest(portletRequest)

PortalUtil.getHttpServletRequest(portletRequest).

推荐答案

查看Liferay 6的源代码(假设您正在谈论6),您可以看到PortalUtil.getOriginalServletRequest所做的工作并将其放置在下面的代码:

Looking at the source code for Liferay 6 (I'm assuming your're talking about 6) you can see what PortalUtil.getOriginalServletRequest does and I've placed the code below:

public HttpServletRequest getOriginalServletRequest(
    HttpServletRequest request) {

    HttpServletRequest originalRequest = request;

    while (originalRequest.getClass().getName().startsWith(
                "com.liferay.")) {

        // Get original request so that portlets inside portlets render
        // properly

        originalRequest = (HttpServletRequest)
            ((HttpServletRequestWrapper)originalRequest).getRequest();
    }

    return originalRequest;
}

因此,正如评论所述,获取原始请求,以便正确呈现portlet中的portlet".对于嵌套的portlet情况或类似情况,您可能只需要这样做.大多数时候,您只需要使用:

So as the comment says, "Get original request so that the portlets inside portlets render properly". You'll probably only require this for a nested portlet situation or similar. Most of the time you will just need to use:

PortalUtil.getHttpServletRequest(portletRequest);

我希望这会有所帮助!

这篇关于PortalUtil.getOriginalServletRequest和PortalUtil.getHttpServletRequest有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 01:11