A negative time indicates the session should never timeout.
负数应该没问题

解决方案 »

  1.   

    我写了一个最简单的程序又测试了一下,
    在test1.jsp中:
    <%
      session.setMaxInactiveInterval(-1);
      session.setAttribute("user",new Integer(10));
    %>
    <A href="./test2.jsp">href</A>在test2.jsp中:
    <%=session.getMaxInactiveInterval()%>
    <br>
    <%=session.getAttribute("user")%>
    刚开始确实输出-1和10
    但如果test1.jsp等一段时间(半小时以上),再链接到test2.jsp,输出:1800和null(恢复默认值了)可能是我使用session的方法不对,请大家帮助!