我经常听到人们说 session 范围对象应该实现Serialized
?为什么会这样呢?如果不这样做,结果会怎样?那么为什么不将其作为 servlet 规范的一部分呢?我知道如果我们不这样做,Tomcat 不会提示。其他应用程序服务器(例如 JBoss、WebSphere 或 Weblogic)怎么样?
最佳答案
This allows the servlet container to either store the contents of a session on disk, or to transfer session contents over the network to another server.
为什么容器需要将session存储在磁盘上(钝化)?也许当内存已满时。当再次需要 session 时,它将其从磁盘检索回内存(激活)。
关于java - 为什么将 session 范围内的对象可序列化视为一种良好实践?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12262759/