Я создал новый путь на конечной точке Каталога. Предполагается принять JSON-представление Продукта и добавить его в базу данных.Как я могу форматировать JSON для Broadleaf Commerce REST API - Wrapper является членом null?
public ProductWrapper insertProduct(HttpServletRequest request, ProductWrapper wrapper)
{
return wrapper;
}
@RequestMapping(value="product",method=RequestMethod.POST)
public ProductWrapper addProduct(HttpServletRequest request, ProductWrapper wrapper){
return insertProduct(request, wrapper);
}
Но когда я положил JSON в тело сообщения. Это не сохраняет его в моей обертке. Мой JSON выглядит так:
{
"id": 1,
"name": "Sudden Death Sauce",
"longDescription": "As my Chilipals know, I am never one to be satisfied. Hence, the creation of Sudden Death. When you need to go beyond... Sudden Death will deliver! ",
"retailPrice": {
"amount": "10.99",
"currency": "USD"
},
"primaryMedia": {
"id": 101,
"title": "Sudden Death Sauce Bottle",
"url": "/cmsstatic/img/sauces/Sudden-Death-Sauce-Bottle.jpg",
"altText": "primary"
},
"active": true,
"activeStartDate": "2017-01-25T16:32:36.993-0500",
"manufacturer": "Blair's",
"defaultCategoryId": 2002,
"productAttribute": [
{
"id": 1,
"productId": 1,
"attributeName": "heatRange",
"attributeValue": "4"
}
],
"media": [
{
"id": 102,
"title": "Sudden Death Sauce Close-up",
"url": "/cmsstatic/img/sauces/Sudden-Death-Sauce-Close.jpg",
"altText": "alt1"
},
{
"id": 101,
"title": "Sudden Death Sauce Bottle",
"url": "/cmsstatic/img/sauces/Sudden-Death-Sauce-Bottle.jpg",
"altText": "primary"
}
]
}
Я ничего не пропустил? Я поставил точку останова, и она ударила. Обертка создается, но все члены имеют значение null.
Спасибо, что сделал трюк. –