我正在尝试通过POST rest API保存对象/详细信息列表(比如我的详细信息是MWLAppMenuConfigDetail)。 我的休息代码是:
public Detail saveMenu(MWLAppMenuConfigDetail[] mwlAppMenuConfigJAXObject)
{
ArrayList<MWLAppMenuConfigDetail> mwlAppDetail = new ArrayList<MWLAppMenuConfigDetail>();
for(int i=0; i <mwlAppMenuConfigJAXObject.length;i++)
mwlAppDetail.add(mwlAppMenuConfigJAXObject[i]);
}
我的JSON是:
[{"appId":"appmn000000000000003","menuId":"appmn000000000000000","render":"1","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000001","render":"1","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000002","render":"0","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000003","render":"0","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"}]
我也尝试过:
{"MWLAppMenuConfigDetail":[{"appId":"appmn000000000000003","menuId":"appmn000000000000000","render":"1","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000001","render":"1","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000002","render":"0","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"},{"appId":"appmn000000000000003","menuId":"appmn000000000000003","render":"0","customImageId":"image000000000001025","authToken":"KfP1yfxgv0R2ZKOgB8ei","insertMode":"true"}]}.
我的请求不会进入休息功能。 当我从输入数据中删除JSON并将函数更改为:
时进行测试public Detail saveMenu()
{
//body
}
它有效,所以我确信rest函数和JSON输入数据的参数定义不兼容。请帮忙。
答案 0 :(得分:0)
哦,我的坏。 JAXBContextResolver中缺少此详细信息(对象)的EN。如果将接受对象数组作为输入,我们需要创建一个条目。