【发布时间】:2016-01-05 11:34:57
【问题描述】:
我正在尝试将 json 数据发送到我的 JAVA 类但出现错误
“执行 POST IntakeFormSections/PostData 失败:org.jboss.resteasy.spi.ReaderException: org.codehaus.jackson.map.JsonMappingException: 无法将 org.json.JSONObject 的实例反序列化出 START_ARRAY 令牌”
控制器:
var datanew = angular.toJson($scope.data);
$http({
url :"http://localhost:8080/......IntakeFormSections/PostData",
method: 'POST',
data : datanew,
headers: {'Content-Type': 'application/Json'},
})};
JAVA代码:
@POST
@Path("/PostData")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String UpdateSiteVisitInfo(JSONObject data) throws JSONException {
System.out.println("++++++++++");
System.out.println(data);
return null;}
【问题讨论】:
-
请求时datanew的内容是什么?
-
-
datanew 的内容是这个 json:- "questions": [{ "Id": 1, "description": "Submitter Contact Information", "type": "hidden", "required": "false", "subquestions1": [{ "Id": "a", "description": "ID", "type": "text", "name": "id", "patternType": "alphanumeric", “必需”:“假”},{“Id”:“b”,“描述”:“名称”,“类型”:“文本”,“名称”:“用户”,“模式类型”:“文本”, “必需”:“假”,“长度”:100 }]
标签: java angularjs json resteasy