Edit method with Spring Boot problem

Asked

Viewed 545 times

0

I created a project in Spring Boot with Thymeleaf and I’m having problems in the implementation that updates the database records, the application is managing to save the records, it is managing to validate the fields now only missing hit the database record editing implementation.

After I can save the records it gives me a success screen right at the top of the screen, and then I go to the bank record listing screen as you can see below;

inserir a descrição da imagem aqui

When I click on the pen icon to edit, it returns to the registration screen being with the data we recovered fields for editing, and when submitting the form it cannot save, and on the edit screen also can not validate the fields if there is a field in whites, how to solve this?

This is the method of editing;

@RequestMapping("/pesquisa/{codigo}")
public ModelAndView edicao(@PathVariable("codigo") Boleto boleto) {
    ModelAndView mv = new ModelAndView("boleto/CadastroBoleto");
    mv.addObject(boleto);
    return mv;
}

in the search page is this part;

<a class="btn btn-link btn-xs" th:href="@{/boleto/pesquisa/{codigo}(codigo=${boleto.codigo})}" 
                                       title="Editar" rel="tooltip" data-placement="top">
                                   <span class="glyphicon glyphicon-pencil"></span>
                               </a>

I’m not seeing anything wrong, I even tried to use the Spring Boot debug, but it crashes my development platform in a way that makes me unable to use it.

the debug I’m referring to would be in the application.properties file

logging.level.root=debug

I do not know if I put the parts that would be necessary for someone to help me, so I am making available my complete project to anyone who wants to take doubt and want to see other parts that are relevant to help me in the project.

https://github.com/wladimirbandeira/boleto

1 answer

0

I believe you’ve already solved the problem. If not, to edit you are passing the boleto ID, but in the controller you do not get this id.

In my project I did it this way and is working perfectly:

@GetMapping("/edit/{id}")
public ModelAndView edit(@PathVariable("id") Long id) {

    return add(userService.findOne(id));

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.