Ola Pessal,
Estou começando a estudar struts. Seguindo um tutorial q encontrei na net, deparei com um erro que não consegui resolve-lo.
Alguem poderia me dar uma ajuda?
Segue o código:
ACTION
public class ListaContatoAction extends Action{
public ActionForward execute(ActionMapping map, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception{
List<Contato> lista = new ContatoDAO().getLista();
request.setAttribute("lista", lista);
return map.findForward("lista");
}
DAO
public class ContatoDAO {
public ContatoDAO() {
}
public List<Contato> getLista() throws SQLException{
List<Contato> lista = new ArrayList<Contato>();
Statement stm = Conexao.getConexao().createStatement();
String sql = "Select senha, login from usuario";
ResultSet rs = stm.executeQuery(sql);
while (rs.next()){
Contato contato = new Contato();
contato.setSenha(rs.getString("senha"));
contato.setLogin(rs.getString("login"));
lista.add(contato);
}
rs.close();
stm.close();
return lista;
}
}
POJO
class Contato {
private String senha;
private String login;
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
}
struts-config.xml
<action path="/contatos" type="src.ListaContatoAction">
<forward name="lista" path="/lista.jsp" />
</action>
JSP
${item.senha} - ${item.login}Como visto no código acima, estou tentando lista senha e login do usuario no meu banco de dados. A lista esta sendo preenchida corretamente. Tanto senha e login são string.
Agora o Erro:
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.el.PropertyNotFoundException: The class ‘src.Contato’ does not have a readable property ‘senha’.
root cause
javax.el.PropertyNotFoundException: The class ‘src.Contato’ does not have a readable property ‘senha’.
note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1_01 logs.
Alguem podesia me ajudar
Obrigado