(转)Strust2 Action设置的session如何在porlet获取
原文:http://blog.csdn.net/moliqin/article/details/5216361
?
在Strust2的Action或Servlet中设置了Session如
ServletActionContext.getRequest().getSession().setAttribute("session1","name");
如何在porlet的jsp/自定义标签获取session?
?
自定义标签中
PortletSession portletSession =(PortletSession)pageContext.findAttribute("portletSession");
String str =(String)portletSession.getAttribute("session1");
jsp中
String str =(String)portletSession.getAttribute("session1");
在strust2的Action中
org.apache.struts2.portlet.servlet.PortletHttpSession p =? (org.apache.struts2.portlet.servlet.PortletHttpSession)ServletActionContext.getRequest().getSession();
?PortletSession portletSession = p.getPortletSession();
String str =(String)portletSession.getAttribute("session1");