Why and how is serialization used in Java web applications?

后端 未结 5 1000
名媛妹妹
名媛妹妹 2020-12-30 05:13

I\'ve been working on a Java web application where the framework insists that everything is Serializable. I assume that this isn\'t specific to the framework but to web app

5条回答
  •  孤城傲影
    2020-12-30 05:58

    Serialization is useful in any application environment, not just web applications.

    One major use for serialization is for transport. You want to copy or move an object to a remote computer, say a UserProfile. You can serialize the UserProfile, send the serialized data (typically XML) and deserialize it to a new object on the receiving end, at which point it can be manipulated as though it were the original object.

    Another use is saving state. You may have a game and you want to save the exact state of a game board. You can serialize the Board object which can subsequently be told to serialize each of its Tiles.

提交回复
热议问题