Hola, pasa que cuando hago un CRUD al confirmar el modal me redirije al index, como hago para que se fije en la misma pagina donde estaba? Estoy usando pagination.
Por ejemplo en el borrar...
<td><a data-toggle="modal" data-target="#removeModalNoticias" class="btn btn-danger delBtn"
th:attr="data-target='#removeModalNoticias'+${noticia.id}">Eliminar
<i class="fa fa-trash"></i> </a> <!-- #Modal for removing noticias --> <div class="modal fade" th:id="removeModalNoticias+${noticia.id}" id="removeModalNoticias" tabindex="-1" role="dialog"
aria-labelledby="removeModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title" id="removeModalCenterTitle">Eliminar
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<p class="alert alert-danger">Are You sure You want to
<div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close
</button> <a th:href="@{/delete/(id=${noticia.id})}" class="btn btn-danger" id="delRef">Delete
</a>
Y en el Controller...
@GetMapping("/delete/{id}")
noticia.deleteById(id);
return "redirect://noticias";
}
Y el listar con pagination buenooo...
@GetMapping(value = "/noticias")
public String findAll
(@RequestParam Map
<String, Object
> params, Model model
) {
int page
= params.
get("page") != null ? Integer.
valueOf(params.
get("page").
toString()) - 1 : 0;
PageRequest pageRequest = PageRequest.of(page, 5);
Page<Noticia> pageNoticia = noticia.findAll(pageRequest);
int totalPage = pageNoticia.getTotalPages();
if (totalPage > 0) {
List<Integer> pages = IntStream.rangeClosed(1, totalPage).boxed().collect(Collectors.toList());
model.addAttribute("pages", pages);
}
model.addAttribute("list", pageNoticia.getContent());
model.addAttribute("current", page + 1);
model.addAttribute("next", page + 2);
model.addAttribute("prev", page);
model.addAttribute("last", totalPage);
return "noticias";
}
Me ayudan?