为什么ActionSupport要实现Serialized
Action 类需要什么可序列化?如果有的话,它会在何时以及如何发生。
What is the need for Action classes to be serializable? When and how does it happen, if at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
据我所知,它不需要是可序列化的,并且让 ActionSupport 实现该接口是一个错误。
这是我在该主题上找到的最佳推理(取自此处):
As far as I can tell, it doesn't need to be Serializable, and it was a mistake to make ActionSupport implement that interface.
Here is the best reasoning I have found on the subject (taken from here):
这个问题可能不再相关,但我认为这可能会有所帮助。
来自 Sun 开发人员网络:
那么为什么你可能想要序列化你的对象呢?这就是你需要坚持他们的状态的时候
这样您就可以稍后使用它们或在另一个 JVM 中使用它们。 JVM 可能位于同一台计算机上,也可能通过网络位于另一台计算机上。我认为
ActionSupport
类的情况也是如此。如果您扩展ActionSupport
,您将有机会序列化您的操作并将其通过网络发送以在另一个 JVM 中使用。This question might not be relevant anymore but I thought this might help.
From Sun developer network:
So why you might want to serialize your objects? That's when you need to persist their state
so you can use them later or in another JVM. The JVM might be on the same machine or over the network on another machine. I think that's the same case for
ActionSupport
class. If you extendActionSupport
you'll get the chance to serialize your action and send it over the network to be used in another JVM.我不知道为什么一定会这样。但操作类必须扩展 ActionSupport。并根据 http://struts. apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html ,ActionSupport 实现了 Serialized。所以什么时候问题的答案,它一直在发生:p
i don't know why it must be so. but action classes must extends ActionSupport. and according to http://struts.apache.org/2.0.6/struts2-core/apidocs/com/opensymphony/xwork2/ActionSupport.html , ActionSupport implements Serializable. so the answer to the when question, it happens all the time :p