Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 29, 2019 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/8e5de8647d52d88e504554c0f49e385b to your computer and use it in GitHub Desktop.
Save parzibyte/8e5de8647d52d88e504554c0f49e385b to your computer and use it in GitHub Desktop.
@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