我有一個portlet,它有一個commandLink。在commandLink的actionListner上,我調用了backingBean。actionResponse.sendRedirect(url)不起作用
支持bean有以下代碼。
ActionResponse actionResponse = (ActionResponse) LiferayFacesContext.getInstance().
getExternalContext().getResponse();
actionResponse.sendRedirect("http://localhost:8080/web/guest/pageName");
我有一個重定向到另一個portlet頁面。這兩個portlet都包含在一場戰爭中。
這種重定向不能正常工作,它給: classCastException. can't clast to ActionResponse
我也試過,
ActionResponse actionResponse= (ActionResponse) FacesContext.getCurrentInstance().
getExternalContext().getResponse();
actionResponse.sendRedirect("http://localhost:8080/web/guest/pageName");
它拋出ClassCastException. Can not cast to ActionResponse
異常堆棧跟蹤:
的Java。 lang.ClassCastException:com.liferay.portle t.ResourceResponseImpl不能轉換爲javax.portlet.ActionResponse 在com.brightsky.action.IPCActionBackingBean.addIPCAction(IPCActionBackingBean.java:63) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl .invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.jboss.el .util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328) at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341) at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java :58) at org.jboss.el.parser.AstValue.invok e(AstValue.java:96) at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102) at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:144) 在javax.faces.event.ActionEvent.processListener(ActionEvent.java:84) 在javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java: 773) 在javax.faces.component.UICommand.broadcast(UICommand.java:296) 處javax.faces.component.UIViewRoot.processApplication javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:781) ( UIViewRoot.java:1246) at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:77) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114) at org.portletfaces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:513) at org.portletfaces.bridge.GenericFacesPortlet.serveResource(GenericFacesPortlet.java:131) at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java: 119) at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:71) at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:92) at javax。 servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internal DoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain。java:206)
注意:我使用Liferay & Icefaces。
謝謝。
嗨,感謝您的回覆。實際上,我在這一行上得到了類轉換異常ActionResponse actionResponse =(ActionResponse)FacesContext.getCurrentInstance()。getExternalContext()。getResponse();它給出,無法投射到ActionResponse。如果我做了類似FacesContext.getCurrentInstance()。getExternalContext()。redirect(url); 。FacesContext.getCurrentInstance()的responseComplete();它給了java.io.UnsupportedEncodingException:只能在ACTION_PHASE –
期間重定向異常說明它實際上是ResourceResponse,請檢查您提出此請求的視圖頁,確保您使用的是正確的請求,而不是 –
yorkw