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

153
Views
Problem with sending checked checkbox list to controller(Spring MVC)

VO

List<String> status;

Controller

@RequestMapping(value="/ed/statusList",method = RequestMethod.POST)
public @ResponseBody Object statusList(HttpServletRequest request, HttpServletResponse response, CurriculumSearchExt ce) throws JsonGenerationException, JsonMappingException, IOException {
   System.out.println(ce.getStatus());
...
}

javascript

$("input[name='status']:checkbox").on('click', function() {
   var checkArr = [];
   $("input[name='status']:checked").each(function() {
      checkArr.push($(this).val());
   });
   console.log("checkArr:" + checkArr);
   if(checkArr.length == 0) {
      checkArr = [""];
   }
   ...//some other parameters
   formdata = {
      ...
      "status" : checkArr
   };
   $("#gridlist").jqGrid("clearGridParam", true);
   $("#gridlist").jqGrid('setGridParam', {
      url : 'ed/statusList',
      datatype : 'json',
      mtype : 'post',
      postData : formdata,
      ajaxGridOptions : {
         traditional : true,
         complete : function(data) {
            console.log('success');
         }
      }
   }).trigger('reloadGrid');
});

HTML

<input type="checkbox" name="status" value="10">a
<input type="checkbox" name="status" value="20">b
<input type="checkbox" name="status" value="30">c
<input type="checkbox" name="status" value="50">d
<input type="checkbox" name="status" value="60">e

When I check 'a', then checkArr:10 is printed at chrome and [10] is printed at server. I check 'b'('a','b' are checked), then checkArr:10, 20 is printed at chrome and [10, 20] is printed at server. and lastly, here is the problem. When I check 'b' again(only 'a' is checked), then checkArr:10 is printed at chrome and [10, 20] is printed at server. If I check 'b' again and uncheck 'a'(only 'b' is checked), then checkArr:20 is printed at chrome and [20,20] is printed at server.

The list 'checkArr' is normally worked at javascript, but controller can`t receive the right things. I want 'checkArr' to go to controller just the way it is.

If you have other things you nead, please comment. Thanks for read.

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!