1

我正在覆盖日历 portlet 的一项操作。我想做一些功能,然后重定向到另一个 JSP。我尝试使用 sendRedirect 函数如下:
1。

String redirect = ParamUtil.getString(actionRequest , "redirect");
actionResponse.sendRedirect(redirect);

2.

actionResponse.sendRedirect ("/calendar/view") ;

3.

ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
PortletURL url = PortletURLFactoryUtil.create(PortalUtil.getHttpServletRequest(actionRequest), "8", themeDisplay.getPlid(),
PortletRequest.RENDER_PHASE);
url.setParameter("struts_action", "/calendar/view");
actionResponse.sendRedirect (url.toString()) ;

但是,这些方法都不会导致 jsp 重定向到另一个。我在 processAction 函数中这样做,并且正在扩展 BaseStrutsPortletAction。

任何建议如何解决它?

这是我的覆盖文件:

public class TestAction extends BaseStrutsPortletAction {
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig,
      ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(actionRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
        //some function
        actionResponse.setRenderParameter("test", "test");
        originalStrutsPortletAction.processAction(portletConfig, actionRequest, actionResponse);
    }
  }

  public String render(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, RenderRequest renderRequest,
      RenderResponse renderResponse) throws Exception {
    String cmdConstants = ParamUtil.getString(renderRequest, Constants.CMD);
    if (cmdConstants.equals(Constants.APPROVE)) {
      if (renderRequest.getParameter("test").equals("test")) {
        return "/portlet/calendar/view.jsp";
      }
    }
    return originalStrutsPortletAction.render(null, portletConfig, renderRequest, renderResponse);
  }
}
4

0 回答 0