Three ways to set the STRUTS2 session expiration date
Source: Internet
Author: User
Method One:
Used anywhere the struts2 frame is used
Servletactioncontext.getrequest (). GetSession (). Setmaxinactiveinterval (XXX);
Method Two:
Defines a HttpServletRequest member object Req in action;
The action class implements the Servletrequestaware interface, which implements the method;
In the implementation of the method written: Req= method parameters;
Then use Req.getsession () anywhere in the action where the session is needed ...
Method Three:
Set the duration of the session in the project's Web. xml
<session-config>
<session-timeout>30</session-timeout>
</session-config>
The session-timeout element is used to specify the default session time-out interval, in minutes. The element value must be an integer. If the value of the session-timeout element is zero or negative, it means that the session will never time out. The value range of the Session-timeout is 1-1440.
Comparison of Setmaxinactiveinterval and Session-config:
1, Setmaxinactiveinterval high priority, if Setmaxinactiveinterval is not set, the default is the time set in Session-config.
2. Setmaxinactiveinterval sets the expiration time of the current session, not the entire Web service.
3, the Setmaxinactiveinterval parameter is the second, Session-config is configured in the Session-timeout is the minute.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service