Estou com um erro meio estranho aqui…
Em uma servlet processo e ponho na sessão um array list.
Esse ArrayLista é composto de Beans:
class Group
{
private int id;
private String description;
public Group(int id, String description)
{
this.id = id;
this.description = description;
}
public int getId()
{ return (this.id); }
public String getDescription()
{ return (this.description); }
public void setId(int id)
{ this.id = id; }
public void setDescription(String description)
{ this.description = description; }
public String toString()
{ return (this.getId() + " - " + this.getDescription()); }
}
Na JSP eu preciso fazer um loop e imprimir essa lista.
Quando uso isso:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:forEach var="group" items="${sessionScope['groups']}">
${group}
</c:forEach>
Ele imprime exatamente o que eu configurei no método toString do bean.
Mas quando tento:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:forEach var="group" items="${sessionScope['groups']}">
${group.id}
</c:forEach>
Ele acusa:
javax.el.PropertyNotFoundException: Property ‘id’ not readable on type java.lang.Integer
E quando eu tento:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:forEach var="group" items="${sessionScope['groups']}">
${group.description}
</c:forEach>
Ele acusa:
javax.el.PropertyNotFoundException: Property ‘description’ not readable on type java.lang.String
O que pode ser?