Struts não imprime certo

2 respostas
wswillianss

Olá,
Minha lista esta saindo assim, no JSP da saída, porque?


Id Nome Descrição Preço Quantidade
${p.id } ${p.nome } ${p.descricao } ${p.preco } ${p.quantidade }

minhas configurações:

package org.loja.modelo;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Produto {
	@Id
	@GeneratedValue
	private Long id;
	private String nome;
	private String descricao;
	private Double preco;
	private Long quantidade;
	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getDescricao() {
		return descricao;
	}
	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	public Double getPreco() {
		return preco;
	}
	public void setPreco(Double preco) {
		this.preco = preco;
	}
	public Long getQuantidade() {
		return quantidade;
	}
	public void setQuantidade(Long quantidade) {
		this.quantidade = quantidade;
	}
}
@SuppressWarnings("unchecked")
	public List<Produto> getLista(){
		return this.session.createCriteria(Produto.class).list();
	}
package org.loja.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.loja.dao.ProdutoDAO;
import org.loja.modelo.Produto;

public class ListarProdutoAction extends Action{
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		List<Produto>lista = new ProdutoDAO().getLista();
		request.setAttribute("produto", lista);
		return mapping.findForward("lista");
	}
}
<action path="/listarProduto" type="org.loja.action.ListarProdutoAction">
    	<forward name="lista" path="/listarProduto.jsp"/>
    </action>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
    <%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><bean:message key="site.titulo"/></title>
</head>
<body>
	<h2><bean:message key="site.titulo"/></h2>
	<h3>Lista de Produtos</h3>
	<hr/>
	<table border="0">
		<tr>
			<th>Id</th>
			<th>Nome</th>
			<th>Descrição</th>
			<th>Preço</th>
			<th>Quantidade</th>
		</tr>
		<c:forEach var="p" items="${produto}">
			<tr>
				<td>${p.id }</td>
				<td>${p.nome }</td>
				<td>${p.descricao }</td>
				<td>${p.preco }</td>
				<td>${p.quantidade }</td>
			</tr>
		</c:forEach>
	</table>
	&lt;h5&gt;<a >Home</a>&lt;/h5&gt;
	&lt;hr/&gt;
	&lt;div align="center"&gt;&lt;bean:message key="site.copyright"/&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

… então, o que há de errado nesse sistema?
estou a horas tentando resolver e nada.

2 Respostas

LucianoM86

Tente colocar essa diretiva no início do seu jsp para ver se funciona:

<%@ page isELIgnored=“false” %>

wswillianss

LucianoM86:
Tente colocar essa diretiva no início do seu jsp para ver se funciona:

<%@ page isELIgnored=“false” %>

Pô, cara valeu mesmo, brigadão! Deu Certo.
Agora voce pode me explicar o porque que no Netbeans, ele funciona sem essa tag?

Criado 10 de novembro de 2008
Ultima resposta 10 de nov. de 2008
Respostas 2
Participantes 2