4

JQuery を使用して、場所の配列を REST サービスに送信したいと考えています。

マイコード

var locations = new Array();
var loc = new Location();
loc.alt = 0;
loc.lat = 0;
loc.long = 0;
loc.time = 1;

locations.push(loc);

var json_data = {value : JSON.stringify(locations)};
console.log(json_data);

$.ajax({type: 'POST',
        url: rootURL + '/Location/123',
        crossDomain: true,
        dataType: "json", // data type of response
        contentType: "application/json; charset=utf-8",
        data: json_data,
        success: function(data, textStatus, jqXHR) {
            console.log('testAddLocations erfolgreich');
        },
        error: function(jqXHR, textStatus, errorThrown) {
            console.log('testAddLocations Fehler');
        }
    });

REST サービス

@POST
@Produces({ MediaType.APPLICATION_JSON })
@Path("{tripID}")
public Response addLocations(@PathParam("tripID") final String tripID, Location[] value) {

しかし、HTTP-500 エラーが発生します。サーバー上:

SCHWERWIEGEND: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
JsonFormatException{text=v, line=1, column=1}
at com.sun.jersey.json.impl.reader.JsonLexer.yylex(JsonLexer.java:662)
at com.sun.jersey.json.impl.reader.JsonXmlStreamReader.nextToken(JsonXmlStreamReader.java:162)
4

1 に答える 1