Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda