• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@xmlrootelement( )

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please explain me what does @xmlrootelement( ) does?
Also which book to read to learn the annotation like @RequestMapping etc
 
Bartender
Posts: 1682
7
Android Mac OS X IntelliJ IDE Spring Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@XmlRootElement is a JaxB annotation. This is not a Spring class but is part of the standard Java libraries.

You often see it used in Spring however in conjunction with Spring's JaxB HTTP Message Converter. When you see an @RequestBody annotation on an object in a Spring controller, and the consumes attribute of the @RequestMapping annotation is "application/xml" (or pre spring 3.1 the Content-Type header is set to "application/xml") this will tell Spring that the payload of the request message is XML and needs to be unmarshalled to the object that was annotated with @RequestBody. In this case the object that was annotated with @RequestBody will typically be annotated itself with JAXb annotations to provide the meta data needed to marshal and unmarshal that object to/from XML, and @XmlRootElement is one of those annotations providing that metadata.

The java doc for @XmlRootElement can be found click --> JAVA DOCS

If you search this forum for 'Spring Book' you will see that the question has been answered many times before. The consensus seems to be Spring in Action 3rd edition is the best place to start.

If you are looking for a free resource try the Spring Reference Documentation
reply
    Bookmark Topic Watch Topic
  • New Topic