Mohamed Reda Arherbi Mohamed Reda Arherbi - 1 month ago 15
Javascript Question

Manipulate java List<Object> in Jquery

I want to manipulate a Java List coming from a controller in my code JQuery (in JSP File).

My list is of type

List<Collaborateur>
.

This is my Controller action:

@GetMapping
public ModelAndView index() {
ModelAndView mv = new ModelAndView("collaborateurs"); //JSP name
mv.addObject("collaborateurs", collaborateurService.getAll()); // ListName
return mv;
}


And I want to show for example the property
email
for my second item in my list.

alert(${collaborateurs.get(2).getEmail});


Thank you for your help.

dit dit
Answer

Use simple index access and variable name:

alert("${collaborateurs[2].email}");
Comments