How to work with javascript object

Asked

Viewed 63 times

0

Well I’m having a hard time understanding how to work with an object that comes from my javascript controller, I’ve already done some tests to make sure that this information has gone up correctly to the view however, do not understand how to work this information in javascript if someone can help I will be grateful.

follows the controller I use to move up the object list

  @RequestMapping(value = "/show/{id}", method = RequestMethod.GET)
    public ModelAndView viewPesquisar(@PathVariable("id") Long id, ModelMap 
    model, HttpServletRequest request) {

    LOGGER.debug(" O id a ser consultado é {}", id);

    List<Ito> optional = itoService.findByIdFetchAll(id);

    if (optional.isEmpty()) {

        LOGGER.debug(" Não foi possivel localizar o Tipo com o Id:{}", id);

        throw new BusinessException("Não foi possivel Localizar o Tipo de Projeto");
    }

    List<Ito> listaCompletaItos = itoService.findByIdFetchAll(id);

    model.addAttribute("listaCompletaItos", listaCompletaItos);

    return new ModelAndView(REQUEST_MAPPING_PAGE_SHOW_ITO);
}

I send the information to the view through Modelandview I can not say if it is the best way in this case.

  • There’s no way you can have one controller no javascript since [tag:javascript] is a client-side language run by the Browser.

  • right the question is how can I work this list within javascript

1 answer

0

You have two ways of doing this! One is writing this information in the header of your page as a Javascript variable and the other is pulling via ajax from Javascript to your controller! Only after you’ve decided which one to use and I can help you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.