search controller spring

0

I try to pass 2 parameters from my angle controller, it's a search form with 2 parameters, I'm using jdbcTemplate

    @RequestMapping(value = "/empleado/buscarEmpleado", method = RequestMethod.POST)
        public ResponseEntity<Void> buscarEmpleado(@RequestBody String ap_pat,String ap_mat, UriComponentsBuilder ucBuilder) {
            //System.out.println("Creando Usuario " + emp.getcUsuario());

//          if (tabEmpleadoRepository.isEmpleadoExiste(emp)) {
//              System.out.println("A User with name " + emp.getCUsuario()+ " already exist");
//              return new ResponseEntity<Void>(HttpStatus.CONFLICT);
//          }



            tabEmpleadoRepository.BuscarFamiliar(ap_pat,ap_mat);
                //int cod=ap_.getnCodEmpleadoPk();

                //tabFamiliarRepository.nuevoFamiliar(fam,cod);

            HttpHeaders headers = new HttpHeaders();
           // headers.setLocation(ucBuilder.path("/empleado/{nCodEmpleadoPk}").buildAndExpand(emp.getNCodEmpleadoPk()).toUri());
               //  headers.setLocation(ucBuilder.path("/empleado/buscarEmpleado").buildAndExpand(emp.getnCodEmpleadoPk()).toUri());
            return new ResponseEntity<Void>(headers, HttpStatus.CREATED);
        }
    
asked by willlu 26.06.2017 в 17:54
source

1 answer

0

Looking at the question it seems that you want to do a POST and send the parameters in the body. To do this you can create a class that contains the parameters:

public class ParametrosBusqueda{
    String ap_pat;
    String ap_mat:
    //getters y setters
}

and the controller function would look like this:

@RequestMapping(value = "/empleado/buscarEmpleado", method = RequestMethod.POST)
public ResponseEntity<Void> buscarEmpleado(@RequestBody ParametrosBusqueda parametrosBusqueda, UriComponentsBuilder ucBuilder) {
    //procesar los valores que están en el objeto parametrosBusqueda
}
    
answered by 27.06.2017 в 13:18