[color=red]action中[/color]
[color=red]jsp中[/color]
User nowUser=userDao.getUser(user.getLoginName(), user.getLoginPassword());
ActionContext ac=ActionContext.getContext();//获得ActionContext
Map app=ac.getApplication();
ac.getSession().put("login",nowUser);//把登录用户放入session中
[color=red]jsp中[/color]
<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>
本文介绍了一个使用Struts2框架实现的简单登录流程。在后台action中通过调用DAO层获取用户信息,并将登录成功的用户信息存入session中。在前端页面利用Struts2标签判断session中是否存在登录用户,从而决定是否显示左侧菜单。
946

被折叠的 条评论
为什么被折叠?



