Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda