我是网络服务的新手,我是编写代码以在 Android 中调用 Jersey 网络服务。但是我得到 null 作为 PathParam 的参数值。请帮助我了解我的代码有什么问题。
以下是Android中Web 服务调用的代码:
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("content-type", "application/json");
JSONObject data = new JSONObject();
try {
data.put("email_id", strEmailId);
data.put("password", strPassword);
Log.d("1", data.toString());
HttpEntity entity;
StringEntity s = new StringEntity(data.toString());
entity = s;
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
}
这是网络服务代码:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/dbconnect")
public String connectToDbTest(@PathParam("email_id") String email_id,@PathParam("password") String password) {
System.out.println(email_id+" "+password);
}