任何人都可以帮助我,
我有一个java文件,我将调用下面的休息服务,
HttpClient client = new DefaultHttpClient();
ObjectMapper mapper = new ObjectMapper();
HttpPost post = new HttpPost("http://localhost:8080/spring-mvc-form/emp/test/");
JSONObject jsonobj = new JSONObject();
jsonobj.put("email","srk@gmail.com");
jsonobj.put("name","test");
StringEntity input = new StringEntity(jsonobj.toJSONString());
post.setEntity(input);
HttpResponse response = client.execute(post);
我正在使用以下代码段接收
@RequestMapping(value = "/test", method = RequestMethod.POST, produces = "application/json",consumes="application/json")
public Employee getEmployeeInJSON(@RequestBody Employee emp) {
System.out.println("entered------------in json---"+emp.getName());
但是当我点击请求时,请求甚至没有进入getEmployeeInJSON()
。
任何人都可以建议我这样做的正确方法是什么?