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

201
Vistas
Sending array of strings from client to jersey server

How can I send an array of strings from client to jersey server? My server method looks like this:

@POST
@Produces(MediaType.APPLICATION_JSON)
public ArrayList<User> createUpdateUser(@NotNull @BeanParam User user) {
    siteDao.addUser(user);
    Collection<User> l = siteDao.listSites();
    ArrayList<User> al = new ArrayList<User>(l);
    return al;
}

User object contains the array of strings - see below.

My Java Script client method (inside my index.html) to prepare user object to be sent to server looks like this:

function getFormUserDetails() {
    var user = {
        servingDates: ['jan','feb']
    }
    return user;
}

My ajax call to the server looks like this:

$(document).ready(() => {
    $('#addUserButtonId').on('click touchstart', (event) => {
        var user = getFormUserDetails();
        $.ajax({
            url: "http://localhost:8080/remote-loader/App/User/",
            type: 'POST',
            data: user, 
            }).done((data, textStatus, xhr) => {
                // some code here
            }).fail((jqXhr, textStatus, errorThrown) => {
                console.log( errorThrown );
            }).always(() => {
            });
        });
    });

My User class looks like this:

public class User /* implements Serializable */ {
    @FormParam("servingDates") 
    private List<String> servingDates = new ArrayList<String>();
    
    public List<String> getServingDates() {
        return servingDates;
    }

    public void setServingDates(List<String> servingDates) {
        this.servingDates = servingDates;
    }
}

The problem I am facing is that user object when method createUpdateUser is called by Jersey contains an empty servingDates array.

about 4 years ago · Juan Pablo Isaza
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