简单点说
    Session   是对针对单个连接来使用的,例如一些登陆用户的信息;  
    Cache   是对全局来定的,例如某些子控件地重复使用,广告等。

Session 在使用中还有一些比较迷惑的地方

Session 和 Cache 的比较HttpSession session =  request.getSession() 与 HttpSession  session =  request.getSession(true)
Session 和 Cache 的比较

有何区别?   
    
  二者在效果上没有区别。request.getSession()会自动调用request.getSession(true)。  
 
  request.getSession(boolean create)  
      如果有与当前的request相关联的HttpSession,那么返回与当前request关联的HttpSession,  
      如果还没有,那么:  
      如果   create   ==   true   那么返回一个新建的HttpSession;  
      如果   create   ==   false,那么返回   null。  

 

相关文章:

  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2021-04-15
  • 2021-05-12
  • 2021-10-20
  • 2022-12-23
猜你喜欢
  • 2021-05-18
  • 2021-12-11
  • 2021-11-04
  • 2022-02-03
  • 2021-08-26
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案