Struts 2 Session Management. I am not able to create session

怎甘沉沦 提交于 2019-12-02 09:44:31
Roman C

The session is already managed in Struts2. If you want to put some object like an user to the session you can use authentication interceptor like this. It checks if an user in session and let the action invoke, otherwise it returns a login result. The user might want to login several times under different accounts, so you should not restrict him/her from doing it. In the JSP you could check the user in session with the if tag using a #session context variable.

<s:if test="#session.user == null">
 <s:a action="login"><s:text name="label.enter"/></s:a>
</s:if>
<s:else>
  <s:a action="logout"><s:text name="label.exit"/></s:a>
</s:else>   
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!