Spring MVC - should my domain classes implement Serializable for over-the-wire transfer?

前端 未结 5 491
误落风尘
误落风尘 2020-12-08 15:10

I\'m trying to learn Spring Boot by implementing a simple REST API.

My understanding was that if I need to transfer an object over the wire, that object should impl

5条回答
  •  余生分开走
    2020-12-08 15:27

    There are many ways to serialize an object. Java's object serialization is just one of them. From the official documentation:

    To serialize an object means to convert its state to a byte stream

    REST APIs usually send and receive JSON or XML. In that case serializing an object means converting its state to a String.

    There is no direct connection between "sending an object over the wire" and implementing Serializable. The technologies you use dictate whether or not Serializable has to be implemented.

提交回复
热议问题