0
I’m having trouble handling a list that comes from my controller in my jsp I believe I’m not using the right way to treat and go through this list
follows my controller who creates the list.
@RequestMapping(value = "/show/{id}", method = RequestMethod.GET)
public ModelAndView viewPesquisar(@PathVariable("id") Long id, ModelMap model, HttpServletRequest request) {
LOGGER.debug(" O id a ser consultado é {}", id);
List<Ito> optional = itoService.findByIdFetchAll(id);
if (optional.isEmpty()) {
LOGGER.debug(" Não foi possivel localizar o Tipo com o Id:{}", id);
throw new BusinessException("Não foi possivel Localizar o Tipo de Projeto");
}
List<Ito> listaCompletaNomeItos = itoService.findByIdFetchAll(id);
model.addAttribute("listaCompletaNomeItos", listaCompletaNomeItos);
and jsp where I should treat the list.
<script>
console.log("${listaNomeItos}");
listaNomeItosSpringArray = "${listaNomeItos}";
listaNomeItosSpringArray = listaNomeItosSpringArray
.replace("]", "");
listaNomeItosSpringArray = listaNomeItosSpringArray
.replace("[", "");
listaNomeItos= listaNomeItosSpringArray.split(",");
$
.each(
listaNomeItos,
function(k, v) {
console.log(v);
$("#containerItos")
.append(
'<div class="col-lg-4 col-md-4 col-sm-12">'+
'<div class="card card-stats">'+
'<div class="card-header" data-background-color="green">'+
' <i class="fa fa-hdd-o "></i>'+
'</div>'+
'<div class="card-content">'+
'<p class="category">Empz</p>'+
'<h4 class="title">'+ v +'</h4>'+
'</div>'+
'<div class="card-footer">'+
'<div class="stats">'+
'<i class="fa fa-file-text-o "Style="color: LightSeaGreen";></i> <a href="${uploadIto}"> Upload de Itos </a>'+
'</div>'+
'</div>'+
'</div>'+
'</div>');
console.log($.trim(v));
console.log($.trim(k));
});
</script>
And what happens? And what do you expect? Please specify your problem.
– Aline
so when I try to climb that way the list doesn’t go to my view
– Wesley Santos
i need this list in order to create an element inside the view that has the name and id of the same object
– Wesley Santos
can debug this js or view the result of: listName?
– Aline
I can debug js but the result of the list is empty because it seems that the information does not subui
– Wesley Santos
And when you debug this: model.addAttribute("listCompletaNomeItos", listCompletaNomeItos) results in the variable?
– Aline
until then the information arrives the problem this up
– Wesley Santos