JSF支持bean应该可序列化吗? [英] JSF backing bean should be serializable?

查看:109
本文介绍了JSF支持bean应该可序列化吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到这些消息:


[#| 2010-07-30T11:28:32.723 + 0000 |警告| glassfish3 .0.1 | javax.faces | _ThreadID = 37; _ThreadName = Thread-1; |将
非序列化属性值设置为
ViewMap :(键:MyBackingBean,值
class:
foo.bar.org.jsf.MyBackingBean)|#]

[#|2010-07-30T11:28:32.723+0000|WARNING|glassfish3.0.1|javax.faces|_ThreadID=37;_ThreadName=Thread-1;|Setting non-serializable attribute value into ViewMap: (key: MyBackingBean, value class: foo.bar.org.jsf.MyBackingBean)|#]

这些是否意味着我的JSF支持bean应该实现Serializable?或者他们是否提到了其他一些问题?

Do these mean that my JSF backing beans should implement Serializable? Or are they refering to some other problem?

推荐答案

是的,你理解正确。视图基本上存储在会话范围中。会话范围在JSF的支持下,由Servlet的 的HttpSession 。所有会话属性都应该实现 可序列化的 ,这是因为普通的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对象。然后 ObjectOutputStream 可用于将它们写入硬盘和 ObjectInputStream 从硬盘读取它们。 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应该可序列化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆