Struts Upload

1 resposta
H

Pessoal To tentando fazer upload com struts e ta me dando erro direto. Ja fiz todos exemplos que achei no google com struts.

Meu Form

private FormFile file;

	public FormFile getFile() {
		return file;
	}

	public void setFile(FormFile file) {
		this.file = file;
	}

Meu Action

public ActionForward salvar(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse respose)
			throws Exception {
		String forward = FORWARD_LISTAR;

		UploadForm uploadForm = (UploadForm) form;

		FormFile file = uploadForm.getFile();

		System.out.println(file.getFileName());

		File caminho = new File(getServlet().getServletContext().getRealPath(
				"/teste"));

		File diskFile = new File(caminho, file.getFileName());
		if (!diskFile.exists())
			diskFile.createNewFile();

		FileOutputStream fos = new FileOutputStream(diskFile);
		fos.write(file.getFileData());
		fos.flush();
		fos.close();

		return mapping.findForward(forward);
	}

ERRO

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: javax.servlet.ServletException: BeanUtils.populate

org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1858)

org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:459)

javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

n Sei mais o q faze.
Se alguem tiver codigo ai q funcione e queira me ajudar Agradeço…

VlW

1 Resposta

felipe_gdr

Tente usar a biblioteca FileUpload da Apache

Criado 9 de novembro de 2007
Ultima resposta 9 de nov. de 2007
Respostas 1
Participantes 2