我在apache-tomcat-6.0.30\conf\web.xml中设置为1分钟,1分钟中却还能从session中取值,为什么呢?
<!-- session过期时间是这样设置的 -->
<session-config>
<session-timeout>1</session-timeout>
</session-config>//这样放进值
ActionContext.getContext().getSession().put("xxx",xxx);//然后我是这样取session值的
ActionContext.getContext().getSession().get("xxx");
<!-- session过期时间是这样设置的 -->
<session-config>
<session-timeout>1</session-timeout>
</session-config>//这样放进值
ActionContext.getContext().getSession().put("xxx",xxx);//然后我是这样取session值的
ActionContext.getContext().getSession().get("xxx");
setMaxInactiveInterval设置的是当前会话的失效时间,不是整个web的时间,单位为以秒计算。session-timeout元素用来指定默认的会话超时时间间隔,以分钟为单位。
而不是tomcat的
现在有个问题,就是ActionContext.getContext().getSession().put("xxx",xxx); 放进一个值xxx,
然后另外一个用户登录,也通过ActionContext.getContext().getSession().put("xxx",xxx); 又放进一个session值,因为名称是一样的,会不会将之前的session踢出?不知道我这想法 对不对?
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee,
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter> <!--定义核心Filter FilterDispatcher -->
<filter-name>struts2</filter-name> <!-- 定义核心Filter的名称 -->
<filter-class> <!--定义核心Filter的实现类 -->
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name><!--核心Filter的名称 -->
<url-pattern>/*</url-pattern><!--使用该核心Filter过滤所有的Web请求 -->
</filter-mapping>
<jsp-config>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</jsp-config>
</web-app>
销毁这个session
http://heisetoufa.iteye.com/blog/227194