Когда я получаю доступ к содержимому GenericMockingForm, его ноль
@Controller
@RequestMapping(value = "/**", produces = "application/json")
public class GenericMockingController {
@Autowired private GenericMockingService genericMockingService;
@ResponseBody
@PostMapping
public ResponseEntity<String> processRequest(@RequestBody GenericMockingForm genericMockingForm, HttpServletRequest request) throws Exception {
String requestURI = request.getRequestURI();
return new ResponseEntity<>(genericMockingService.getJsonResponse(genericMockingForm, requestURI), HttpStatus.OK);
}
}
public class GenericMockingForm {
private List<String> productIds;
private String salesChannelId;
private Locale locale;
public List<String> getProductIds() {
return productIds;
}
public void setProductIds(List<String> productIds) {
this.productIds = productIds;
}
public String getSalesChannelId() {
return salesChannelId;
}
public void setSalesChannelId(String salesChannelId) {
this.salesChannelId = salesChannelId;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
}
test payload and ulr http://localhost:8088/product/get-products:
{
"product_ids": ["1420-15595-82", "1420-58134-82"],
"sales_channel_id": "www-k24-at",
"locale": "de_DE"
}
Над моим кодом
Как десериализовать полезную нагрузку запроса?Когда я получаю доступ к содержимому GenericMockingForm, его ноль
java.lang.NullPointerException
at com.kfz24.mockingservice.service.impl.GernericMockingServiceImpl.getJsonResponse(GernericMockingServiceImpl.java:32)
at com.kfz24.mockingservice.controller.GenericMockingController.processRequest(GenericMockingController.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)