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

149
Views
Problema con el envío de la lista de casillas marcadas al controlador (Spring MVC)

VO

 List<String> status;

Controlador

 @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

Cuando verifico 'a', checkArr:10 se imprime en Chrome y [10] se imprime en el servidor. Verifico 'b' ('a', 'b' están marcados), luego checkArr:10, 20 se imprime en Chrome y [10, 20] se imprime en el servidor. y por último, aquí está el problema. Cuando reviso 'b' nuevamente (solo se verifica 'a'), checkArr:10 se imprime en Chrome y [10, 20] se imprime en el servidor. Si vuelvo a marcar 'b' y desmarco 'a' (solo se marca 'b'), entonces checkArr:20 se imprime en Chrome y [20,20] se imprime en el servidor.

La lista 'checkArr' normalmente se trabaja en javascript, pero el controlador no puede recibir las cosas correctas. Quiero que 'checkArr' vaya al controlador tal como está.

Si tienes otras cosas que necesitas, por favor comenta. Gracias por leer

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!