Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Which type is considered to be a FormData when handled from ajax.post to java through struts 2?

I haven´t found any answer in the forum, however it's possible the question has yet been asked. Sorry in advance, if that's the case.
Basically, I'm creating a FormData object in a jsp to capture an uploaded file and I would like to access it in my java Dispatcher. I tried the type FormData in java, but it looks like it doesnt exist.
Any help would be appreciated.
Here is the .jsp code:

var file_data = $("#fileUpload").prop("files")[0];   
   var file_name = $("#fileUpload").val();
   var form_data = new FormData();                  
   form_data.append("file", file_data);              
   form_data.append("fileName", file_name);  

       $.post('crearNuevaActa.action',
    {
    processData: false, 
    contentType: false,
    data: form_data,
    }
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

First convert your formData to JSON

var myFormData = JSON.stringify(form_data);

on your jQuery post change data to:

data:  "data:"+data,

On your action class include following,

private List<MyBean> data;

//setter and getter

Define MyBean POJO class;

class MyBean{
//include  file filename and any other field you have 
//getter setter
}

configure your action class to deserialize JSON

<action name="" class="">
    <result type="json"/>
  <interceptor-ref name="json">
  <interceptor-ref name="defaultStack">
</action>
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda