我在尝试在Liferay 6.0 portlet中设置会话cookie时遇到问题.我希望能够将cookie设置到客户端浏览器以存储用于linkedin身份验证的应用程序密钥,然后可以由其他portlet检索它.
我可以通过以下方式阅读cookie:
public void addLinkedInCV(ActionRequest request, ActionResponse response)
throws PortalException, SystemException {
HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(request);
Cookie[] cookies = convertReq.getCookies();
...
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试阅读一个失败的尝试.
@Override
public void doView(RenderRequest renderRequest,RenderResponse renderResponse) throws IOException, PortletException {
HttpServletResponse convertRes = PortalUtil.getHttpServletResponse(renderResponse);
HttpServletResponse originalRes = (HttpServletResponse) ((HttpServletResponseWrapper) convertRes).getResponse();
Cookie linkedInCookie = new Cookie("linkedIn", util.getAppKey());
originalRes.addCookie(linkedInCookie);
}
Run Code Online (Sandbox Code Playgroud)