获得Json的宁静服务

时间:2017-06-25 18:26:31

标签: web-services jersey

我在泽西岛有一个Restful服务,我返回Json数据,问题是当我尝试用$ .ajax获取数据时我无法得到它。 我的宁静服务是:

@Path("/RegistroJson")
public class RegistroJson {

@GET
@Path("/get/{param}/{param2}/{param3}")

@Produces(MediaType.APPLICATION_JSON)
public Usuario htmlHello(@PathParam("param") String nick,@PathParam("param2") String pass,@PathParam("param3") String email) {
    Usuario u=new Usuario();
    u.setPass(pass);
    u.setUser(nick);
    u.setEmail(email);
    return u;
}

我需要网络中的json,但我无法用它来获取它:

$.ajax({url: "http://localhost:8080/RestWebService/rest/RegistroJson/get/emilio/adf/asdf"})

我在该服务中使用该命令(http://rest-service.guides.spring.io/greeting)并且它正常工作所以我认为问题出在我的休息服务中 你能帮帮我吗? 谢谢

1 个答案:

答案 0 :(得分:0)

如果你使用浏览器访问这个休息网址,你会收到json数据吗?在$ .json()中,您需要在可以访问收到的数据时添加成功操作。您可以通过添加{}选项success:function(f){ console.log(f) }

来执行此操作
相关问题