Javascript 无法将数据从cline发送到服务器

Javascript 无法将数据从cline发送到服务器,javascript,java,angularjs,jersey-2.0,Javascript,Java,Angularjs,Jersey 2.0,我尝试从js调用java后端 角度js(http://localhost:8082/dev/index.html#/): java(应响应localhost:8082/api/Voices/updateVoice @Path("/Voices") public class VoicesOperation { ... @Path("/updateVoice") @PUT @Produces(MediaType.APPLICATION_JSON + ";charset=u

我尝试从js调用java后端

角度js(
http://localhost:8082/dev/index.html#/
):

java(应响应
localhost:8082/api/Voices/updateVoice

@Path("/Voices")
public class VoicesOperation {

...

    @Path("/updateVoice")
    @PUT
    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
    public void updateVoice(VoiceBl voice) throws Exception {

        fillVoicesSnapshot();
我得到一个js例外:

TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.
    at Function.remoteFunction (<anonymous>:3:14)
    at errorCallback (http://localhost:3002/public/js/components/voice-form-component.js:54:29)
    at http://localhost:3002/bower_components/angular/angular.min.js:133:460
    at m.$eval (http://localhost:3002/bower_components/angular/angular.min.js:147:313)
    at m.$digest (http://localhost:3002/bower_components/angular/angular.min.js:144:421)
    at m.$apply (http://localhost:3002/bower_components/angular/angular.min.js:148:78)
    at HTMLButtonElement.<anonymous> (http://localhost:3002/bower_components/angular/angular.min.js:282:247)
    at cg (http://localhost:3002/bower_components/angular/angular.min.js:38:299)
    at HTMLButtonElement.d (http://localhost:3002/bower_components/angular/angular.min.js:38:246)
TypeError:“调用者”和“参数”是受限制的函数属性,无法在此上下文中访问。
at Function.remoteFunction(:3:14)
错误回调(http://localhost:3002/public/js/components/voice-表单组件(js:54:29)
在http://localhost:3002/bower_components/angular/angular.min.js:133:460
以百万美元估价(http://localhost:3002/bower_components/angular/angular.min.js:147:313)
m.$digest(http://localhost:3002/bower_components/angular/angular.min.js:144:421)
以万美元申请(http://localhost:3002/bower_components/angular/angular.min.js:148:78)
在HTMLButtoneElement(http://localhost:3002/bower_components/angular/angular.min.js:282:247)
在cg(http://localhost:3002/bower_components/angular/angular.min.js:38:299)
在HTMLButtonElement.d(http://localhost:3002/bower_components/angular/angular.min.js:38:246)

问题在于您的资源文件,您没有发送任何东西,也没有消费。如果您发送的是响应,则返回类型应为响应,并且您还需要消费

@Path("/Voices")
public class VoicesOperation {

...

    @Path("/updateVoice")
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
    public Response updateVoice(VoiceBl voice) throws Exception {
        Voice voice = fillVoicesSnapshot();
        return Response.status(Status.CREATED)
                       .entity(voice)
                       .build();
    }
}
或者,如果您发送的是语音类型,那么您的返回类型应该是语音

@Path("/Voices")
public class VoicesOperation {

...

    @Path("/updateVoice")
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
    public Voice updateVoice(VoiceBl voice) throws Exception {

        return fillVoicesSnapshot();
    } 
}
@Path("/Voices")
public class VoicesOperation {

...

    @Path("/updateVoice")
    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
    public Voice updateVoice(VoiceBl voice) throws Exception {

        return fillVoicesSnapshot();
    } 
}