您的位置:首页 > 其它

Strust2 Action设置的session如何在porlet获取

2010-01-20 11:08 609 查看
在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");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐