KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My java servlet returns a json string in this way: Gson gson = new Gson(); String lista = gson.toJson(utenti); System.out.println(lista); request.setAttribute("lista", lista); request.getRequestDispatcher("GestioneUtenti.jsp").forward(request, response); now, in the jsp page I want to have my arrayList again. I try to do this: <% String lista = (String)request.getAttribute("lista"); Gson gson = new Gson(); ArrayList<Utente> users = gson.fromJson(lista, TypeToken.get(new ArrayList<Utente>().getClass()).getType()); out.println(users.get(0).getUsername()); %> I have this exception: java.lang.ClassCastException: com.google.gson.internal.StringMap cannot be cast to classi.Utente can Youu help me? If i miss some particulars tell me! thanks :-)
Tags (comma-separated)
Save Edits
Cancel