@RequestMapping("/registrar") public ModelAndView initLogin(@ModelAttribute Registro registro, Model model) { System.out.println( "REGISTRO: " + registro.getUsername() + " EMAIL: " + registro.getEmail()); repository.save(new Registro(registro.getUsername(), registro.getEmail())); return this.lista(new ModelAndView()); }
@RequestMapping("/lista") public ModelAndView lista(ModelAndView model) { registros = (ArrayList<Registro>) repository.findAll(); for (Registro registro : registros) { System.out.println( "USUARIO: " + registro.getUsername() + " EMAIL: " + registro.getEmail()); } model.setViewName("lista"); model.addObject("registros", registros); return model; }