Spring Framework
  1. Spring Framework
  2. SPR-8381

HttpMessageConverter doesn't support typed collections

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Complete
    • Affects Version/s: 3.0.5
    • Fix Version/s: 3.2 M2
    • Component/s: Web
    • Labels:
      None

      Description

      HttpMessageConverter can't support conversion to typed collections.

      Example: Use JacksonJsonMessageConverter to convert a json string to a Collection<Pojo> objects.

      Since only a Class<? extends T> is specified, there's no way to declare both the type (Pojo.class) and the object (Collection.class).

      Jackson classes support this using a TypeReference class (see: http://wiki.fasterxml.com/JacksonInFiveMinutes#Data_Binding_with_Generics)

      Also, MappingJacksonJsonMessageConverter (line 104) is using a deprecated method of the current release of Jackson.

        Issue Links

          Activity

          Hide
          delphi23 added a comment -

          Why the issue is not resolved until now?
          I encounter the same problem on SpringMVC 3.1.1

          Show
          delphi23 added a comment - Why the issue is not resolved until now? I encounter the same problem on SpringMVC 3.1.1
          Hide
          Rossen Stoyanchev added a comment -

          Linking to SPR-7023 since a solution for the RestTemplate would likely involve a similar enhancement to the message converters.

          Show
          Rossen Stoyanchev added a comment - Linking to SPR-7023 since a solution for the RestTemplate would likely involve a similar enhancement to the message converters.
          Hide
          Rossen Stoyanchev added a comment -

          There is now a new GenericHttpMessageConverter that can read content given a java.lang.reflect.Type, which can be a ParameterizedType.

          The new GenericHttpMessageConverter is implemented by the MappingJacksonMessageConverter and a new Jaxb2CollectionHttpMessageConverter that can read a generic Collection where the generic type is a JAXB type annotated with @XmlRootElement or @XmlType.

          Show
          Rossen Stoyanchev added a comment - There is now a new GenericHttpMessageConverter that can read content given a java.lang.reflect.Type , which can be a ParameterizedType . The new GenericHttpMessageConverter is implemented by the MappingJacksonMessageConverter and a new Jaxb2CollectionHttpMessageConverter that can read a generic Collection where the generic type is a JAXB type annotated with @XmlRootElement or @XmlType .

            People

            • Assignee:
              Rossen Stoyanchev
              Reporter:
              David Parks
              Last updater:
              Rossen Stoyanchev
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                1 year, 35 weeks ago