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

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

问题描述

我收到这些消息:

[#|2010-07-30T11:28:32.723+0000|警告|glassfish3.0.1|javax.faces|_ThreadID=37;_ThreadName=Thread-1;|设置不可序列化的属性值ViewMap: (key: MyBackingBean, value班级: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?

推荐答案

是的,你理解正确.视图基本上存储在会话范围内.会话范围在由 Servlet 的 支持的 JSF 中HttpSession.所有会话属性都应该实现 Serializable,这是因为一般的 servletcontainer 可能会将会话数据持久化到硬盘等,以便能够与集群中的其他服务器共享,或者承受重负载,或者在服务器重启期间恢复会话.

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天全站免登陆