Estou com um problema aqui no listar, pq ele direciona para a página certa mas não exibe nenhuma lista. Está com stacktrace de ‘javax.servlet.jsp.JspException: Cannot create iterator for this collection’
vou colar os códigos aki.
meu struts-config.xml
[code]
<action path="/item" type="br.com.ufrj.action.itemHomeAction" name="optionBean" input="/admin_itemHome.jsp" scope="request" validate="false">
<forward name="inserir" path="/admin_itemInserir.jsp" />
<forward name="listar" path="/admin_itemLista.jsp" />
<forward name="voltar" path="/admin_index.jsp" />
</action>
<action path="/updateItem" type="br.com.ufrj.action.UpdateActionItem"
name="BeanItem" input="/admin_itemInserir.jsp" scope="request" validate="true">
<forward name="successo" path="/admin_index.jsp" />
<forward name="voltar" path="/admin_index.jsp" />
</action>
<action path="/listaItem" type="br.com.ufrj.action.listActionItem"
name="BeanItem" input="/admin_itemLista.jsp" scope="request" validate="true" >
<forward name="voltar" path="/admin_index.jsp" />
</action>
<!--Item -->[/code]
meu jsp
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<html>
<head>
<title>Gerenciamento de Hotel</title>
</head>
<body>
<h1>Gerenciamento de Itens</h1>
<h1>Gerenciamento de Itens</h1>
<h1>Gerenciamento de Itens</h1>
<html:form action="listaItem.do">
<div id="container">
<br>
<logic:iterate id="lista" name="BeanItem">
aaaa<bean:write name="BeanItem" property="nome"/>
</logic:iterate>
</div>
</html:form>
</body>
</html>
meu action [code]
package br.com.ufrj.action;
import br.com.ufrj.item.;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.;
public class listActionItem extends Action {
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
HttpSession session = request.getSession();
ActionMessages messages = new ActionMessages();
ActionErrors erros = new ActionErrors();
DAOItem dao = new DAOItem();
ArrayList<BeanItem> list = new ArrayList<BeanItem>();
list = dao.selectAllItems();
request.setAttribute("lista",list);
return mapping.findForward("ok");
}
}
[/code]
minha DAO de acesso ao banco
[code]
public ArrayList selectAllItems() throws Exception {
try {
String query = "SELECT * " + "FROM item " + "ORDER BY id ";
xConn = new XConnection();
xConn.rs = xConn.seleciona(query);
ArrayList<BeanItem> lItem = new ArrayList<BeanItem>();
while (xConn.rs.next()) {
BeanItem item = new BeanItem();
item.setId(Integer.parseInt(xConn.rs.getString(1)));
item.setNome(xConn.rs.getString(2));
item.setDescricao(xConn.rs.getString(3));
item.setValor(Float.parseFloat(xConn.rs.getString(5)));
lItem.add(item);
}
xConn.fechaConexao();
return lItem;
} catch (SQLException e) {
System.out.println("erro selectAllItens: " + e.toString());
xConn.fechaConexao();
return null;
} catch (Exception e) {
System.out.println("erro select All Itens: " + e.toString());
xConn.fechaConexao();
return null;
}
}[/code]
Desculpe por tantos códigos , mas é mais facil identificar assim.
Obrigado galera.