【发布时间】:2016-01-30 20:24:18
【问题描述】:
我对在 AngularJS 应用程序中进行对象映射感到震惊。
在 html 中,我有大约 10 行,每行有一个标签和 2 个日期字段。
每一行都映射到一个java对象,如下所示
public class RowObject {
private Long id;
private String label;
private Date startDate;
private Date endDate;
// getters / setters
}
我正在尝试使用如下的 html 代码
<div class="form-group">
<label class="control-label col-md-3">Row 1</label>
<div class="input-group col-md-4">
<input id="startDate1" type="text" class="form-control" ng-model="entity.rowObjects[0].startDate">
<input id="endDate1" type="text" class="form-control" ng-model="entity.rowObjects[0].endDate">
<input type="text" ng-model="entity.rowObjects[0].id" ng-value="1" style="display: none;">
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3">Row 2</label>
<div class="input-group col-md-4">
<input id="startDate2" type="text" class="form-control" ng-model="entity.rowObjects[1].startDate">
<input id="endDate2" type="text" class="form-control" ng-model="entity.rowObjects[1].endDate">
<input type="text" ng-model="entity.rowObjects[1].id" ng-value="1" style="display: none;">
</div>
</div>
错误信息
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
at [Source: org.apache.cxf.transport.http.AbstractHTTPDestination$1@40cc74d9; line: 1, column: 2] (through reference chain: com.jai.model.Entity["rowObjects"])
【问题讨论】:
-
如果我的回答通过接受/评论解决了您的问题,请告诉我:)
-
@IggY 我正在尝试做同样的事情,但它不起作用。使用angularjs在html上显示java对象
标签: javascript java angularjs rest