Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:45:35+00:00 2026-05-27T00:45:35+00:00

I have created a JS array like this var detailsArr = new Array(); and

  • 0

I have created a JS array like this var detailsArr = new Array(); and pushing some data into this array.

Now i push this array via Ajax to my Spring Controller like this

$.ajax({
            type: "POST",
            url: "submit",
            data: ({detailsArr : detailsArr }),
            success: function(html){
              alert( "Submitted");
                }
          });

At the Spring Controller side , i receive this array through the @RequestBody annotation. The Spring Controller method signature looks like this

public String submit(@RequestBody String body) 

But the array when received at the Spring Controller side is basically a String of this format

detailsArr[]=add&detailsArr[]=test1&detailsArr[]=test2&detailsArr[]=test3

I have to manually split this String to get the values, this is a cumbersome process. Is there any way in which I can get the array as it is , so that I just have to iterate over it to get the values.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:45:35+00:00Added an answer on May 27, 2026 at 12:45 am

    you should pass your array to server in json format. And convert it by using Json to object converter. you can use Gson.

    client side:

    $.ajax({
                type: "POST",
                url: "submit",
                data:JSON.stringify(detailsArr),
                success: function(html){
                  alert( "Submitted");
                    }
              });
    

    server side :

    public String submit(@RequestBody String body){
    //convert body to array using JSONLib, FlexJSON or Gson
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array created with this code: var widthRange = new Array(); widthRange[46]
I have created an element like this: var myDiv = new Element('div'); myDiv.update('Hello!'); I
I'm inserting some items into array with randomly created indexes, for example like this:
I have a mock being created like this: var mock = new Mock<IPacket>(MockBehavior.Strict); mock.Setup(p
I have a JSON array like this: { forum:[ { id:1, created:2010-03-19 , updated:2010-03-19
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
This is a really basic question but... I have some code like this var
Lets say I have an array like this: string [] Filelist = ... I
I have created a form like this: class Form_Login extends Zend_Form { public function
I have an array called as wcs declared using var wcs= new Array(); .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.