简体   繁体   English

如何将自定义类的对象从Android发送到Java Server?

[英]How to send an object of custom class from Android to Java Server?

I have created several classes in android client application corresponding to each database table (just like concept of Entity-Objects). 我在android客户端应用程序中创建了几个对应于每个数据库表的类(就像实体对象的概念一样)。

i want to retrieve data from database of the server to android client application and then assign that returned data set to objects of those created classes to further process the data and apply some logic. 我想从服务器的数据库检索数据到Android客户端应用程序,然后将返回的数据集分配给那些创建的类的对象,以进一步处理数据并应用一些逻辑。

I also want send data from android to server in the form of objects to process them on server or insert/update in the database. 我还希望以对象的形式从android发送数据到服务器,以便在服务器上处理它们或在数据库中插入/更新。

(I can send the data to Servlet using HttpClient and HttpPost but don't know how to send objects and how to receive result set of database in the form of objects). (我可以使用HttpClient和HttpPost将数据发送到Servlet,但不知道如何发送对象以及如何以对象的形式接收数据库的结果集)。

I'm new to client-server programming so my this approach might be wrong, if so then please correct me. 我是客户端服务器编程的新手,所以我的这种方法可能是错的,如果有的话请纠正我。 any sample code will be appreciated. 任何示例代码将不胜感激。

normally you would send some kind of String to the server which represents your Object. 通常你会将某种String发送到代表你的Object的服务器。 You could do that by generating JSON. 你可以通过生成JSON来做到这一点。 There are nice libraries like GSON which can help you with that GSON这样的好库可以帮助你

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 JSON 响应对象从自定义类发送到另一个活动 android - How to send JSON response object from custom class to another activity android 如何使用 Retrofit 将包含图像的类从 Android 发送到 Java Restful Web 服务器 - How to send class which contain Image from Android to Java Restful Web server using Retrofit 如何使用kSOAP从Android向.NET发送/接收自定义对象? - How to send/receive a custom object from Android to .NET using kSOAP? 如何将 json 对象从我的 android 应用程序发送到服务器 - How To Send json Object to the server from my android app 如何将JsonArray从客户端(java或Android)发送到servlet(服务器) - How to Send JsonArray From Client(java or Android ) To servlet(Server) 如何将数据从Android发送到服务器上的Java应用程序 - How to send data from android to java application on server 如何将数据从Android应用程序发送到Java Server(Apache tomcat)? - How to send data from Android application to Java Server(Apache tomcat)? 如何使用GCM从Java服务器向Android应用程序发送通知? - How to send notification to Android app from Java server using GCM? 将 JSON 对象从 android 发送到 php 服务器 - send a JSON object from android to php server 将数据从Android移动版发送到Java服务器 - Send data from Android mobile to java server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM