閱讀353 返回首頁    go 阿裏雲 go 技術社區[雲棲]


設置session過期的各種方式(主要看weblogic的方式)

一、web.xml

設置WEB應用程序描述符web.xml裏的<session-timeout>元素。這個值以分鍾為單位,並覆蓋weblogic.xml中的TimeoutSecs屬性,此例表示Session將在54分鍾後過期。
<session-config>
    <session-timeout>54</session-timeout>
</session-config>
當<session-timeout>設置為-2,表示將使用在weblogic.xml中設置的TimeoutSecs這個屬性值。
當<session-timeout>設置為-1,表示Session將永不過期,而忽略在weblogic.xml中設置的TimeoutSecs屬性值。該屬性值可以通過console控製台來設置


二、weblogic.xml

設置WebLogic特有部署描述符weblogic.xml的<session-descriptor>元素的TimeoutSecs屬性。這個值以秒為單位。該文件放在項目的web-inf下。
<session-descriptor>
   <session-param>
      <param-name>TimeoutSecs</param-name>
      <param-value>3600</param-value>
   </session-param>
</session-descriptor>
默認值是3600秒


三、jsp中控製

session.setmaxinactiveinterval(7200); session是默認對象,可以直接引用,單位秒s


四、servlet中控製

httpsession session = request.getsession();
session.setmaxinactiveinterval(7200);單位秒s

 

節選自:https://tonyaction.blog.51cto.com/227462/201900/

最後更新:2017-04-03 15:21:43

  上一篇:go Java麵向對象基礎--對象數組
  下一篇:go hdu 4707 Pet 水