0

私は、Liferay ポータル サーバーで Spring Portlet-MVC フレームワークと Velocity を使用するプロジェクトに取り組んでいます。いくつかのページについては、安全な接続で提供する必要があります。ポートレットにかなり慣れていないので、Action-Method にリンクしてそこからリダイレクトするという解決策を思いつきました。

@ActionMapping(params = "command=secureRedirect")
public void actionSecureRedirect(ActionRequest request, ActionResponse response) {
    HttpServletRequest servletRequest = PortalUtil.getHttpServletRequest(request);
    String absoluteUrl = servletRequest.getRequestURL().toString();
    String[] urlComponents = StringUtils.split(absoluteUrl, '/');
    StringBuffer redirectUrl = new StringBuffer("https://");
    redirectUrl.append(urlComponents[1]);
    redirectUrl.append("<specificPath>");
    response.sendRedirect(redirectUrl.toString());
}

私の解決策はうまくいきますが、私にはあまりいいとは思えません。誰かがこれを行うための別のより透過的な方法を考えることができるかどうか疑問に思っていました (おそらく RenderMappings でインターセプターとアノテーションを使用しますか?)。

どんな提案でも大歓迎です!

4

2 に答える 2

2

一部のページとは、Liferay ページのことですか、それとも、ユーザーがポートレットから何らかのリンクをクリックしたときに生成される URL が気になるだけですか。

ポートレットの一部のリンクを安全にしたい場合は、liferay-portlet フレーバーまたは renderURL または actionURL を使用します。secure という属性があり、これを true に設定すると、URL は https で始まります

安全なライフレイ ページ (/web/guest/mypage など) を探している場合は、一種のハックであり、これを誰にもお勧めしませんが、他に選択肢がない場合は、サービスを作成できます。事前にフックして、懸念している URL パターンをチェックし、その URL の https バージョンにリダイレクトします。

于 2012-03-23T13:12:40.337 に答える
1
write this code in controller 


 protected PortletURL getRedirectURL(ActionRequest actionRequest) {
        ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
        String portletName = (String) actionRequest.getAttribute(WebKeys.PORTLET_ID);
        PortletURL redirectURL = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), portletName, themeDisplay.getLayout().getPlid(),
                PortletRequest.RENDER_PHASE);
        return redirectURL;
    }

@ActionMapping(params="something")
public void save(ActionRequest actionRequest, Other parameters){



/.....Your code



.....//
 redirectURL = getRedirectURL(actionRequest);
 actionResponse.sendRedirect(redirectURL.toString());
}
于 2012-05-10T11:56:15.253 に答える