我的方法是这样的:
@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实现请愿时,对象“批注”它始终为空
PETITION REST
我应该怎么做才能起作用?我无法修改Java代码作为API的一部分。只能修改de REST Petition
答案 0 :(得分:1)
如前所述,如果要将数据传输到控制器,则需要使用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) {
....
}