如何使会话数据可序列化 [英] How do I make the session data serializable
问题描述
之前我们已经实施了粘性会话。
Previously we have implemented sticky session.
以下是我们环境的链接: apache中的粘滞会话不起作用
Here's the link on our environment: Sticky Session in apache doesn't work
我们的下一个任务是实现会话复制。
Our next task is to implement session replication.
我们目前正在使用tomcat示例 cart.jsp
来演示此行为。
We are current using tomcat example, cart.jsp
to demonstrate this behavior.
据说所有会话属性都必须实现java.io.serializable。
It is said that all session attribute must implement java.io.serializable.
你有什么提示吗?在哪里实施它?我们正在密切关注本教程。
Do you have any tips on where to implement it? We are following this tutorial closely.
tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html
推荐答案
java.io.Serializable是一个所谓的标记接口。它不包含任何方法。因此,要使某些类的对象可序列化,您不必实现任何操作。只需将Serializable添加到您实现的接口列表中。
java.io.Serializable is a so-called marker interface. It contains no methods. So to make objects of some class serializable you don't have to implement anything. Simply add Serializable to the list of interfaces you class implements.
ie:
class MyClass implements Serializable {
}
这篇关于如何使会话数据可序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!