serialization - 为什么 ActionSupport 实现 Serializable

标签 serialization struts2

Action 类需要序列化吗?它何时以及如何发生,如果有的话。

最佳答案

据我所知,它不需要是可序列化的,让 ActionSupport 实现该接口(interface)是错误的。

这是我在该主题上找到的最佳推理(取自 here):

It's very common in web frameworks to use Serializable objects for a couple or reasons, such as being able to preserve state across a server restart and for shipping objects around in a cluster.

With that said, (IMHO) I believe it was a design mistake to have ActionSupport implement Serializable. I don't believe that either of the above really apply to Action objects since they are short-lived. The choice of making Actions Serializable should have been left to the developer and not "forced" by the framework.

关于serialization - 为什么 ActionSupport 实现 Serializable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4790636/

相关文章:

session - 在 struts2 中获取 session 的最佳和推荐方法?

jakarta-ee - struts2 : Invalid field value for field?

java - 调用struts2 action的简单方法

jsp - OGNL/Struts2 JSP 将 bean 分配给一个对象

c# - MongoDB 反序列化/对象的反序列化

java.util.LinkedList.Node<E> 无法分配给 GWT Serialized?

.net - 反序列化文件中的数据。性能问题

json - 如何对原始的、未转义的 JSON 字符串进行编码?

java - struts2如何设置UTF-8字符编码

jquery - JSON 和 jQuery 的问题