I have a problem with this request, I did not understand it because I have another one using the long in the id and it is functional, but this returns this error whenever I try, really I do not understand much of Spring so this is difficult to solve.
@RequestMapping(value = "/novopost", method = RequestMethod.POST)
public String savePost(@Valid Post post, @PathVariable("id") long id){
post.setData(LocalDate.now());
Usuario usuario = usuarioRepository.findById(id);
System.out.println(usuario);
post.setUsuarios(usuario);
System.out.println(post);
postService.save(post);
return "redirect:/time-line";
}
Error
There was an unexpected error (type=Internal Server Error, status=500). Missing URI template variable 'id' for method parameter of type long org.springframework.web.bind.MissingPathVariableException: Missing URI template variable 'id' for method parameter of type long