日期:2014-05-17 浏览次数:20840 次
$.ajax( {
url : '/Test/services/update',
type : 'post',
data : '{"1":"1","2":"2"}',
dataType : 'json',
contentType:'application/json',
async : false,
success : function(data) {
alert("success");
alert(data.name);
alert(data.age);
},
error : function() {
alert("ajax error");
}
});
@POST
@Path("/update")
@Produces("application/json")
//@Produces(MediaType.APPLICATION_JSON)
public Person update(HashMap map) {
System.out.println("aaaaaaaaaaa");
System.out.println(map.get("1"));
System.out.println(map.get("2"));//这里取不到,而且还报错
// Map<String,Person> aa = new HashMap<String,Person>();
// aa.put("1", new Person("aaa","123"));
// aa.put("2", new Person("BBB","456"));
System.out.println("bbbbbbbbbbb");
//return new GenericEntity<Map<String, Integer>> (aa){};
return new Person("test","test");
}
@GET
@Path("/requestTest")
@Produces("application/json")
public Person update(@Context HttpServletRequest request) {
System.out.println("request:" + request.getParameter("a11"));
System.out.println("request:" + request.getParameter("a22"));
System.out.println("request:" + request.getQueryString());
return new Person("testPerson", "33");
}