简体   繁体   中英

Best method to sending an object to a Spring MVC controller

What is the most efficient (uses least amount of bandwidth) method of sending a java bean from a java application to a Spring MVC servlet?

I am currently using XML, but I think it's using more bandwidth and more time to serialize the bean into XML because it is more verbose, which I do not need, because it's being transferred directly from one application to another, where no person is actually reading the serialized data.

JSON could be an option I guess..

What I understand here is that the two applications are not in the same VM and you need a way to pass on data between these two application. If it is so, here I would suggest you to use below approach:

  1. Try using Java's default serialization and stream the output to next application.

  2. Optionally, you should use a compression mechanism (like gzip api in java) to compress the serialized file.

  3. Also, if you want to stick with XML version, you can add compression step to reduce the size of the xml. This should be a minimal code change, if it is an existing application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM