Skip to content Skip to sidebar Skip to footer

Post JS Object Array To Spring MVC Controller

I am trying to pass long array from jquery load to spring controller. How can i sent js object array t spring mvc controller. Every time action occured the no data alert on script

Solution 1:

The JSON array resides in the body of the request. You can use the @RequestBody annotation to obtain the array if you have Jackson on the classpath to deserialize the JSON.

saveUserRating(@RequestBody(required=false) String[] ids)

If you want to use the array as the response body simply return the array from the handler method. It will be serialized to JSON automatically.

@ResponseBody
public String[] saveUserRating(saveUserRating(@RequestBody(required=false) String[] ids)) {
    return ids;
}

Post a Comment for "Post JS Object Array To Spring MVC Controller"