Como você importou sua classe “net.app.MateriaPrimaService” ? Qual o comando que você usou na página?
Provavelmente você deve ter usado algo como “net.app.MateriaPrimaService.". Aí realmente acho que vai dar esse erro. Use “net.app.MateriaPrimaService” ou então, mais preguiçosamente, "net.app.”
M
Mauricio_Linhares
Coloca o JSP aí.
M
moonlight
Ptz, eu ia colocar o JSP mas esqueci :oops:
Aí vai:
<%@tagliburi="/tags/struts-bean"prefix="bean"%><%@tagliburi="/tags/struts-html"prefix="html"%><%@tagliburi="/tags/struts-logic"prefix="logic"%><%@pageimport="net.app.MateriaPrimaService"%><%@pageimport="java.util.List"%><html:htmllocale="true"><head><title>CadastraMateriaPrima</title><html:base/></head><bodybgcolor="white"><html:errors/><%ListmateriaPrimaList=MateriaPrimaService.getInstance().getMateriaPrimaList();request.setAttribute("materiaPrima",materiaPrimaList);%><p>Listademateriasprimasnobancodedados:</p><tableborder=1><!-- This code will iterate over the list of items, creating a table row for each item. --><logic:iterateid="element"name="items"scope="request"type="net.app.MateriaPrima"><tr><td><bean:writename="element"property="codigo"/></td><td><bean:writename="element"property="nome"/></td><td><bean:writename="element"property="descricao"/></td><td><bean:writename="element"property="unidade"/></td><td><bean:writename="element"property="custo"/></td><td><bean:writename="element"property="estoqueMinimo"/></td></tr></logic:iterate></table><p>Adicionarumitem:</p><!-- This form will post the submitted data to the addItem Action Mapping --><html:formaction="addMateriaPrima.do"method="post"><tableborder=1><tr><td>codigo:</td><td><html:textproperty="codigo"/></tr><tr><td>nome:</td><td><html:textproperty="nome"/></tr><td>descrição:</td><td><html:textproperty="descricao"/></td></tr><tr><td>unidade:</td><td><html:textproperty="unidade"/></tr><tr><td>custo:</td><td><html:textproperty="custo"/></tr><tr><td>estoqueminimo:</td><td><html:textproperty="estoqueMinimo"/></tr></table><br/><html:submit/></html:form></body></html:html>
Testei mudando pra “net.app.*” mas deu a mesma coisa
M
Mauricio_Linhares
Faça assim:
<%@ page import="net.app.*,java.util.*" %>
M
moonlight
Obrigada, Mauricio. Mudou o erro, mas acredito que o erro novo ainda é relacionado:
Essas classes estão dentro de “/WEB-INF/classes/net/app”?
M
moonlight
O caminho completo é:
C:\Arquivos de programas\Apache Software Foundation\Tomcat 5.5\webapps\CadastroMP\WEB-INF\classes\net\app
Lá é onde estão todos os meus arquivos .class
(acabei de conferir e MateriaPrimaService.class está lá)
M
Mauricio_Linhares
Pelo que eu vi, você tá usando o Struts, faça o seguinte, crie um action e no execute desse action você coloca o resultado da chamada desse método aí (MateriaPrimaService.getInstance().getMateriaPrimaList() ) do mesmo jeito que ele tá no JSP:
List materiaPrimaList = MateriaPrimaService.getInstance().getMateriaPrimaList();
request.setAttribute("materiaPrima", materiaPrimaList);
Aí você dá um forward pra esse JSP, que vai ficar mais ou menos assim:
<%@tagliburi="/tags/struts-html"prefix="html"%><%@tagliburi="http://java.sun.com/jsp/jstl/core"prefix="c"%><html:htmllocale="true"><head><title>CadastraMateriaPrima</title><html:base/></head><bodybgcolor="white"><html:errors/><p>Listademateriasprimasnobancodedados:</p><tableborder=1><!-- This code will iterate over the list of items, creating a table row for each item. --><c:forEachitems="${materiaPrima}"var="materia"><tr><td>${materia.codigo}</td><td>${materia.nome}</td><td>${materia.descricao}</td><td>${materia.unidade}</td><td>${materia.custo}</td><td>${materia.estoqueMinimo}</td></tr></c:forEach><p>Adicionarumitem:</p><!-- This form will post the submitted data to the addItem Action Mapping --><html:formaction="addMateriaPrima.do"method="post"><tableborder=1><tr><td>codigo:</td><td><html:textproperty="codigo"/></tr><tr><td>nome:</td><td><html:textproperty="nome"/></tr><td>descrição:</td><td><html:textproperty="descricao"/></td></tr><tr><td>unidade:</td><td><html:textproperty="unidade"/></tr><tr><td>custo:</td><td><html:textproperty="custo"/></tr><tr><td>estoqueminimo:</td><td><html:textproperty="estoqueMinimo"/></tr></table><br/><html:submit/></html:form></body></html:html>
Vê aí no que é que dá.
M
moonlight
Ptz, que forma estranha de se resolver um problema heheeh