Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
How pass an array javascript in the data of ajax that call a servlet

My problem it's that I define an ajax request to a servlet, and send in the ajax request a javascript array of Object defined in js. In java I have also a bean Class with same name e method. How can I read this array in java servlet? Because

This is my js (I want to send String, and one array of IngQua object):

var list= [];
---fill list---
$.ajax({
    type: "POST",
    url: "/insert",
    data: {
        title:title,
        description:description,
        prep:prep,
        list:list,
        advice:advice
    },  
    success: function(res){
        if(res === "OK")
            alert("OK");
    },
    error: function(xhr){
        
    }
})

While this is my servlet

@PostMapping("/insert")
@ResponseBody
public String insert(@RequestParam("title") String titolo, @RequestParam("description") String description, 
        @RequestParam("prep")String prep,@RequestParam("advice") String advice, ,
     @RequestParam("list") ArrayList<IngQua> list, HttpServletRequest req ) {
    System.out.println(titolo);
    return "OK";
    
}

And this is the exception:

Resolved [org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'list' for method parameter type ArrayList is not present]
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!