Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Jersey Ajax POST错误415(不支持的媒体类型)_Jquery_Json_Rest_Jaxb - Fatal编程技术网

Jquery Jersey Ajax POST错误415(不支持的媒体类型)

Jquery Jersey Ajax POST错误415(不支持的媒体类型),jquery,json,rest,jaxb,Jquery,Json,Rest,Jaxb,我的请求没有到达服务器。。。我看过很多例子,但我找不到错误。我在GAE上穿的是运动衫 这是我接收请求的资源类 @Path("/preMatricula") public class PreMatriculaRS { @GET @Path("/get") @Produces(MediaType.APPLICATION_JSON) public String getPreMatricula(){ return "Primeira requisicao..."; } @POST @Path

我的请求没有到达服务器。。。我看过很多例子,但我找不到错误。我在GAE上穿的是运动衫

这是我接收请求的资源类

@Path("/preMatricula")
public class PreMatriculaRS {

@GET
@Path("/get")
@Produces(MediaType.APPLICATION_JSON)
public String getPreMatricula(){
    return "Primeira requisicao...";
}

@POST
@Path("/save")
@Consumes(MediaType.APPLICATION_JSON)
public void savePreMatricula(Academico academico){
    //code goes here
}

}
那是我的Pojo

@XmlRootElement
public class Academico {

private String nome;
private String cpf;
private String email;

public String getNome() {
    return nome;
}
public void setNome(String nome) {
    this.nome = nome;
}
public String getCpf() {
    return cpf;
}
public void setCpf(String cpf) {
    this.cpf = cpf;
}
public String getEmail() {
    return email;
}
public void setEmail(String email) {
    this.email = email;
}
}
这是我的jquery函数

(function($) {
    var path = "/rs";

    preMatricula = {};

    preMatricula.salvar = function(){
        var data = $('#myForm').serializeObject();
        var urlFor = path + "/preMatricula/save";
        $.ajax({
              type:'POST',
              url: urlFor,
              data: JSON.stringify(data),
              dataType: 'json',
              contentType : "application/json",
              async : false

        });
    }
})(jQuery);$
可能重复的