Erro no struts

2 respostas
L

Olá pessoal esta dando o seguinte erro no eclipse :

init:

deps-jar:

Compiling 1 source file to C:\Luiz Fernando\Java\Projetos (teste)\struts\web_struts\build\web\WEB-INF\classes

C:\Luiz Fernando\Java\Projetos (teste)\struts\web_struts\src\br\com\javafree\CadastrarFuncionarioAction.java:20: cannot find symbol

symbol  : variable funcionarioDTO

location: class br.com.javafree.CadastrarFuncionarioAction

BeanUtils.copyProperties( funcionarioDTO, funcionarioForm );

C:\Luiz Fernando\Java\Projetos (teste)\struts\web_struts\src\br\com\javafree\CadastrarFuncionarioAction.java:21: cannot find symbol

symbol  : variable funcionarioDTO

location: class br.com.javafree.CadastrarFuncionarioAction

request.setAttribute(funcionario,funcionarioDTO);

2 errors

C:\Luiz Fernando\Java\Projetos (teste)\struts\web_struts\nbproject\build-impl.xml:212: The following error occurred while executing this line:

C:\Luiz Fernando\Java\Projetos (teste)\struts\web_struts\nbproject\build-impl.xml:91: Compile failed; see the compiler error output for details.

BUILD FAILED (total time: 2 seconds)

********** Ja criei as seguintes classes *************

package br.com.javafree;

import org.apache.struts.action.Action;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

import org.apache.struts.action.ActionForm;

import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public final class CadastrarFuncionarioAction extends Action {

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
    throws Exception {
    FuncionarioForm funcionarioForm = (FuncionarioForm) form;
    FuncionarioDTO FuncionarioDTO = new FuncionarioDTO();
    BeanUtils.copyProperties( funcionarioDTO, funcionarioForm );
    request.setAttribute("funcionario",funcionarioDTO);
    return (mapping.findForward("sucesso"));
}

}

package br.com.javafree;

public class FuncionarioDTO {

private String nome;

private int idade;
public void setNome(String nome) {
    this.nome = nome;
}
public void setIdade(int idade) {
    this.idade = idade;
}
public String getNome() {
    return nome;
}
public int getIdade() {
    return idade;
}

}


package br.com.javafree;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class FuncionarioForm extends ActionForm {

private String nome;
private String idade;

public void setName(String nome) {
    this.nome = nome;
}
public void setIdade(String idade) {
    this.idade = idade;
}
public String getNome() {
    return nome;
}
public String getIdade() {
    return idade;
}

}

2 Respostas

A

Oi irmão.
Procure colocar tag code nos seus códigos.
Fica mais legível e as chances de alguém responder são maiores.

P

cara …vc criou uma referencia e esta tentando usar outra

FuncionarioDTO FuncionarioDTO = new FuncionarioDTO();
BeanUtils.copyProperties( funcionarioDTO, funcionarioForm );
request.setAttribute("funcionario",funcionarioDTO);

FuncionarioDTO - F maisculo
funcionarioDTO

Criado 20 de julho de 2006
Ultima resposta 20 de jul. de 2006
Respostas 2
Participantes 3