---
title: "struts2 token session过期问题"
author: "east_java"
date: "2010-01-17T14:23:45Z"
tags: []
categories: ["企业架构"]
slug: "struts2-token-session"
draft: false
lastmod: "2010-01-17T14:23:45Z"
id: 572729
url: "https://japi.iteye.com/blog/572729"
---

在使用struts2 token防止重复提交表单的时候，填写表单时间长了，这个时候就会提示 重复提交表单的错误。

感觉这应该是session过期了，

如果把session过期时间变长，那会浪费资源呢。

 

这个怎么解决呢？可以设置通过单个页面的session的有效时间来解决。

 

使用session.setMaxInactiveInterval()方法来实现，这样子就可以不用在web.xml下设置全局的session过期时间，浪费资源。

 

参照资料：

```
session-timeout(web.xml)元素与session.setMaxInactiveInterval()函数
```

```
<s:token>的源代码分析
```