我正在覆盖日历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);
}
}