Results 1 to 2 of 2

Thread: Ajax json Jackson

  1. #1
    Join Date
    Nov 2010
    Posts
    6

    Red face Ajax json Jackson

    Hi, am trying to get a List of an object as a json view from my controller, but somehow its not working at all : here is my controller :
    PHP Code:
        @RequestMapping(value "ajaxLoad"method RequestMethod.GET)
        public @
    ResponseBody List<Mail> list(@RequestParam(value "type"required trueString type){
            List<
    Mailmails mailService.getUserMails((LongWebHelper.getPrincipal().getUser().getId(),type);
            
            return 
    mails;
        } 
    its supposed to return a list of mails as a json view.
    but i got errors : l it s trying to redired to the view ajaxLoad.jsp which doesnt exists.

    i have added the jackson json library in my app.
    In the Keith Donald tutorials, he said that "Underneath the covers, Spring MVC delegates to a HttpMessageConverter to perform the serialization. In this case, Spring MVC invokes a MappingJacksonHttpMessageConverter built on the Jackson JSON processor. This implementation is enabled automatically when you use the mvc:annotation-driven configuration element with Jackson present in your classpath."
    What if am not using the mvc:annotation, how to implement it manually?

    thanks for any adivse

  2. #2

    Default

    Hi,

    You can use ContentNegotiatingViewResolver as described here: http://static.springsource.org/sprin...epresentations

    But I highly recommend switching to <mvc:annotation-driven/> - it reduces the amount of configuration dramatically and you can still override the behavior explicitly if you need to.
    Gabriel Axel
    Sparklix | Blog | Twitter | Github

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •