Spring mvc practical series of tutorials (5)--convert objects to XML output

spring mvc output XML format

 

1. Add DispatcherServlet's interception of URL requests suffixed by xml to the web.xml of the application


 
 
2. Add view processing configuration in xml format to spring mvc configuration file
1) Add the mapping relationship between xml media types and extensions in mediaTypes


 
 
2) Add beans for processing XML type views, Jaxb is used here, and Marshallers such as Xstream and castor can also be used


 
 

3. Add the maven dependency on the corresponding marshaller in the pom file, here is the dependent oxm




 

4. Write entity beans, add xml binding annotations to classes, and remember to provide getters and setters



 
5. Write the handle method, there is nothing special, the entity classes can be nested with each other to form the hierarchical relationship of XML,
Special processing is done by the configured marshaller, powerful


 
 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326524545&siteId=291194637