lch
lch

Reputation: 4931

spring mvc ajax data truncated with Jackson

0: {id: 1, name: "installation", description: "installing",…}

1: 2

2: 3

Above shown is an o/p of ajax. has any one faced or know why the data in 1 and 2 objects is missing. i tried to print the response list on server side. its ok there, all the value are printed. but when it comes to client side, data is missing

@RequestMapping(value="/events/month", method=RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody List<Event> getEventsForMonth()
{
    List<Event> events= eventService.getEventsForMonth();
    for(Event event:events)
        System.out.println(event.getName());

    return events;
}

Upvotes: 0

Views: 522

Answers (1)

luboskrnac
luboskrnac

Reputation: 24571

Your code should produce JSON array of even objects: [{"id":...}, {"id":...}].

First of all try to sniff the payload (e.g. via Zed Attach Proxy or Fiddler) to confirm that Spring + Jackson are not including more than one Event object.

If that is the case try to verify is there isn't any strange configuration of MappingJackson2MessageConverter in you Spring application. Try to remove it and observe behavior with default Jackson configuration.

Upvotes: 1

Related Questions