在Struts2中获得session对象的方法

action中


User nowUser=userDao.getUser(user.getLoginName(), user.getLoginPassword());

  ActionContext ac=ActionContext.getContext();//获得ActionContext 
	       Map app=ac.getApplication(); 
	       ac.getSession().put("login",nowUser);//把登录用户放入session中 
	      


jsp中

<s:if test="#session.login!=null">
   	 	 <td width="152" height="580" style="background-color:#f5f3f4;" valign="top">
    	 <iframe src="studentLeft.action" scrolling="no"  frameborder=0 height="100%" width="100%"></iframe>
    	 </td>
     </s:if>

你可能感兴趣的:(java,jsp,idea)