Home > Back-end >  The return value is the XML format springboot specify a method
The return value is the XML format springboot specify a method

Time:09-16

Both rely on I tried, it is make all return values into XML format, I just want a certain method returns the XML, what method?

Com. Fasterxml. Jackson. Jaxrs
Jackson - jaxrs - XML - provider
2.4.3 & lt;/version>


Com. Fasterxml. Jackson. Dataformat
Jackson -- dataformat xml
2.9.8 & lt;/version>

CodePudding user response:

 @ RequestMapping (path="myProduces", produces=MediaType APPLICATION_XML_VALUE) 
@ ResponseBody
Public MyData returnXmlValue () {
Return the getData ();
}

CodePudding user response:



No the converter for [* * * * * * * * *] with preset the content-type 'null'

CodePudding user response:

reference 1st floor kse_music response:
 @ RequestMapping (path="myProduces", produces=MediaType APPLICATION_XML_VALUE) 
@ ResponseBody
Public MyData returnXmlValue () {
Return the getData ();
}


At the wrong
No the converter for [* * * * * * * * * * *] with preset the content-type 'null'

CodePudding user response:

Resolved
After introducing the dependence, all return values into XML format

So I need to return the json format method, combined with the,


Tried before in the method directly use the produces MediaType=. APPLICATION_XML_VALUE)
An error: No converter for [* * * * * * * * * * *] with preset the content-type 'null'
Now also don't know why

CodePudding user response:

reference 4 floor qq_33305549 response:
resolved
After introducing the dependence, all return values into XML format

So I need to return the json format method, combined with the,


Tried before in the method directly use the produces MediaType=. APPLICATION_XML_VALUE)
An error: No converter for [* * * * * * * * * * *] with preset the content-type 'null'
Now also don't know why

Implementation and integration of the two try
Extends AbstractHttpMessageConverter
Implements GenericHttpMessageConverter

Then add a converter can support contentType for MediaType. APPLICATION_XML_VALUE serialization operation.
How the converter is added to the spring system can search and XML and springboot code configuration can be sort of

If you don't understand this can be as simple as spring abstract a serialization/deserialization interface provides users, Jackson/fastjson have implement the converter interface, relevant XML is not clear, you can get one myself, interface is fairly simple
Org. Springframework. HTTP. Converter. HttpMessageConverter
I wrote above AbstractHttpMessageConverter and GenericHttpMessageConverter just spring provides some abstract classes to simplify implementation function, you can also directly implement
Org. Springframework. HTTP. Converter. HttpMessageConverter

The relative partial bottom, this solution is not clear how you level, is likely to go


  • Related