我用弹簧靴和百里香
我试图保存一个对象列表。
我的目标。
public class GECPD {
public Integer id;
public String name;
public List<GEPD> geL;
public Integer giId;
public Integer sGEId;
}
在我的控制器中,我返回一个对象列表
Set<GECPD> gECL = new HashSet<>();
...
model.addAttribute("gECL", new ArrayList<>(gECL));
数据显示正确
<input name="id[0]" type="hidden" value="136">
<select name="sGEId[0]" class="form-control">
<option value="246">01</option>
<option value="391">00</option>
</select>
我的控制器
@PutMapping(value = "/{id}/ge")
public ResponseEntity updateGE(@PathVariable("id") Integer id, @RequestBody List<GECPD> dto) {
....
return new ResponseEntity(dto,HttpStatus.OK);
}
函数savegroundelement(){
var form = transForm.serialize('#gEForm');
var url = "/rest/spi/" + $("#spi").val() + "/ge";
form = JSON.stringify(form);
jQuery.ajax({
type: "put",
url: url,
contentType: "application/json",
data: form,
success: function (data, status, jqXHR) {
},
error: function (jqXHR, status) {
checkError(jqXHR);
}
});
}
发送的数据
{"id":["136"],"sGEId":["246"]}
我得到这个结果
错误代码:{“时间戳”:“2018-06-29T15:36:58.427+0000”,“状态”:
400,“error”:“错误请求”,“消息”:“json解析错误:无法”
反序列化的实例
java.util.ArrayList
不在起始位置
令牌;嵌套异常是
com.fasterxml.jackson.databind.exc.mismatchedinputException:无法
反序列化的实例
java.util.ArrayList
不在起始位置
标记位于[源:(pushbackinputstream);行:1,列:1]“,
“path”:“/rest/spi/1/ge”}
知道吗?