我的方法是:
@RequestMapping(value = "/asignar", method = RequestMethod.GET, headers = "Accept=application/json")
public @ResponseBody
ResponseViewEntity<ResultadoJSON> asignar(
@RequestParam(required = true, value = "usuario") String usuario,
@RequestParam(required = true, value = "clienteId") Long clienteId,
ListaLotes lotes) {
....
}对象ListaLotes
public class ListaLotes {
private List<LoteForm> lotes;
}对象LoteForm
public class LoteForm {
private Long loteId;
private Long cantidad;
}但是当我通过PostMan意识到这个请求时,这个对象总是“But”它的null
请愿休息
我应该怎么做才能让它起作用?我不能修改我的Java代码,它是API的一部分。只能修改反REST请愿书
发布于 2019-06-27 14:51:37
如前所述,如果要将数据传输到控制器,则需要使用POST方法并将参数标记为@RequestBody。
// or @PostMapping
@RequestMapping(value = "/asignar", method = RequestMethod.POST, headers = "Accept=application/json")
public @ResponseBody
ResponseViewEntity<ResultadoJSON> asignar(
@RequestParam(required = true, value = "usuario") String usuario,
@RequestParam(required = true, value = "clienteId") Long clienteId,
@RequestBody ListaLotes lotes) {
....
}https://stackoverflow.com/questions/56785236
复制相似问题