问题描述
我收到这些消息:
这些是否意味着我的JSF支持bean应该实现Serializable?或者他们是否提到了其他一些问题?
Do these mean that my JSF backing beans should implement Serializable? Or are they refering to some other problem?
推荐答案
是的,你理解正确。视图基本上存储在会话范围中。会话范围在JSF的支持下,由Servlet的。所有会话属性都应该实现,这是因为普通的servlet容器可能会将会话数据持久存储到硬盘中,以便能够与群集中的其他服务器共享,或者承受重负载,或者在服务器期间恢复会话重新开始。
Yes, you understood it correctly. The view is basically stored in the session scope. The session scope is in JSF backed by the Servlet's HttpSession
. All session attributes are supposed to implement Serializable
, this because the average servletcontainer may persist session data to harddisk among others to be able to share with other servers in a cluster, or to survive heavy load, or to revive sessions during server restart.
只有当相应的类实现 Serializable
时,才能在硬盘上存储原始Java对象。然后可用于将它们写入硬盘和从硬盘读取它们。 servletcontainer透明地管理这一切,你实际上不需要担心它。 JSF只是发出警告,以便您了解风险。
Storing raw Java objects on harddisk is only possible if the respective class implements Serializable
. Then ObjectOutputStream
can be used to write them to harddisk and ObjectInputStream
to read them from harddisk. The servletcontainer manages this all transparently, you actually don't need to worry about it. JSF is just giving a warning so that you understand the risks.
这篇关于JSF支持bean应该可序列化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!