2种liferay portlet 之间传至方法。
NO.1
portlet.xml
message1 message1 x:message1
对参数进行赋值的话,就是在Action中用下面这句话:
actionResponse.setRenderParameter("参数名", 参数值);
获取的话,就直接像取其它参数一下直接获取:
在Action中,String 变量 = ParamUtil.getString(request, "参数名", "默认值");
在JSP中,<%=renderRequest.getParameter("参数名")%>
NO.2
liferay-portlet.xml
false false
public String index() { HttpServletResponse resp = ServletActionContext.getResponse(); org.apache.struts2.portlet.servlet.PortletServletResponse struts2Resp = (org.apache.struts2.portlet.servlet.PortletServletResponse) resp; HttpServletRequest req = ServletActionContext.getRequest(); org.apache.struts2.portlet.servlet.PortletHttpSession strutsSession = (org.apache.struts2.portlet.servlet.PortletHttpSession) (req .getSession()); if(Validator.isNull(message)){ message = (String)strutsSession.getPortletSession().getAttribute("message",PortletSession.APPLICATION_SCOPE); } strutsSession.getPortletSession().setAttribute("message", message, PortletSession.APPLICATION_SCOPE); return SUCCESS; }
String message = (String)renderRequest.getPortletSession().getAttribute("message",PortletSession.APPLICATION_SCOPE); renderRequest.setAttribute("message", message);