首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

(转)Strust2 Action设置的session怎么在porlet获取

2012-09-03 
(转)Strust2 Action设置的session如何在porlet获取原文:http://blog.csdn.net/moliqin/article/details/52

(转)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");

热点排行