📜  为什么要对 java bean 使用可序列化 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:20.801000             🧑  作者: Mango

代码示例1
/*
One good reason, with respect to servlets, is that if you put 
serializable beans into your web server session, your web server can 
serialize them to disk if it's shutting down, and then deserialize them 
back into memory when it starts up. In this way, users wouldn't lose 
their sessions / logins when the server comes back up.
  
If there are any non-serializable beans in session, tomcat will fail to 
serialize sessions to disk.
I believe it's also necessary if you want to sync sessions between 
multiple servers in a cluster.
*/