2
I need to implement a success message that is shown via json, by when my message is returning this way below;
I don’t know how to implement that message, I tried that way;
@PostMapping
public ResponseEntity<Employee> criar(@Valid @RequestBody Employee employee, BindingResult result, HttpServletResponse response, Model model) {
model.addAttribute("mensagem", "Cadastro de Employee feita com sucesso");
Employee employeeSalva = employeeRepository.save(employee);
URI uri = ServletUriComponentsBuilder.fromCurrentRequestUri().path("/{codigo}")
.buildAndExpand(employeeSalva.getId()).toUri();
response.setHeader("Location", uri.toASCIIString());
return ResponseEntity.created(uri).body(employeeSalva);
}
I tried to use the method addAttribute, however I was unsuccessful, please ,could someone help me in the code so I can implement a message of success?