Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/rest/5.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
Javascript 如何通过主干将自定义对象传递给REST?_Javascript_Rest_Backbone.js - Fatal编程技术网

Javascript 如何通过主干将自定义对象传递给REST?

Javascript 如何通过主干将自定义对象传递给REST?,javascript,rest,backbone.js,Javascript,Rest,Backbone.js,我有如下REST web服务: @POST @Path("/test") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public void testObject(final CustomVO customVO) private String id; private String name; private CountryVO countryVO; private List<Sho

我有如下REST web服务:

@POST
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void testObject(final CustomVO customVO)
private String id;
private String name;
private CountryVO countryVO;
private List<ShopbranchesVO> shopBranchesList
private Long id;
private String name;
自定义VO如下所示:

@POST
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public void testObject(final CustomVO customVO)
private String id;
private String name;
private CountryVO countryVO;
private List<ShopbranchesVO> shopBranchesList
private Long id;
private String name;
类似地,ShopbranchesVO将有一些字段

现在我想在主干中填充这个自定义对象,并将其传递给testObject()REST web服务。如何将主干中的列表(在我的ShopbranchesVO列表中)设置为对象?

这个如何

将这行代码放入渲染函数中

    formData = {
    // all your parameters here
    param1: param1,
    param2: param2

}
$.ajax({
    type: 'POST',
    contentType: 'application/json',
    url: "https://www.example.com/test",
    dataType: "json",
    data: formData,
    success: function(data) {
        //success handling
    },
    error: function(data) {
        //error handling
    }
});

您可以将web服务的json输出放在这里吗。主干集合接受对象数组,并自动为您创建模型集合。