@PostMapping(value = "/agregar") | |
public String guardarProducto(@ModelAttribute @Valid Producto producto, BindingResult bindingResult) { | |
if (bindingResult.hasErrors()) { | |
// Aquí se puede hacer cualquier cosa, yo hago una redirección para mostrar los errores en el form | |
return "productos/agregar_producto"; | |
} | |
// Si llegamos hasta aquí es que no hubo errores | |
return "redirect:/productos/mostrar"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment