Post JS Object Array to Spring MVC controller

前端 未结 1 1937
[愿得一人]
[愿得一人] 2021-01-26 16:22

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

相关标签:
1条回答
  • 2021-01-26 16:42

    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;
    }
    
    0 讨论(0)
提交回复
热议问题