<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <session-config>
    <session-timeout>1</session-timeout>
  </session-config>
  <welcome-file-list>
    <welcome-file>login.jsp</welcome-file>
  </welcome-file-list>
</web-app>

解决方案 »

  1.   

    修改或添加下段:
    <session-config>
       <session-timeout>
          30
       </session-timeout>
    </session-config>
    注意,<session-config>必须紧跟在<servlet>标记的后面.
      

  2.   

    to  chenzhiqiang(惘):没明白什么意思,我的web.xml中好多servlet啊~~哪个后面????
    是在tomcat的server.xml还是在我的项目中的web.xml中配置?to:wellsoon(wellsoon) ( ) 
      <web-app>
      <session-config>
        <session-timeout>1</session-timeout>
      </session-config>
      <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
      </welcome-file-list>
    </web-app>
    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
      </welcome-file-list>
    做什么用?没想到这么个简单的问题还这么麻烦
      

  3.   

    <welcome-file-list>
        <welcome-file>login.jsp</welcome-file>
      </welcome-file-list>
    是定义默认文档的。比如:
    在地址栏打开http://localhost:8080/test/的时候,默认会打开http://localhost:8080/test/login.jsp.
      <web-app>
      <session-config>
        <session-timeout>1</session-timeout>
      </session-config>
      </web-app>
    你只要放在   <web-app>与 </web-app>之间就可以了。问题很简单的,一点也不麻烦,你实际操作一下就明白了。
      

  4.   

    可以在web.xml里面设置
    也可以在程序中
    session.setMaxInactiveInterval(分钟数)
    来控制
      

  5.   

    是在web.xml里设置的。至于我说的要放在servlet后面,是新的规范的要求,可从sun的网站上找到说明。如果不是用2.3规范,倒不必要加在servlet后面,你可以试试看。不过,如果是tomcat 4.1.24以上版本,是要求放在servlet后面的,否则不生效。
      

  6.   

    直接看这个文件呀
    http://java.sun.com/dtd/web-app_2_3.dtd