Qiita's first post. (Also serves as a trial post)
Originally ~~ POJO ~~ To automatically convert object type variables to Response in json / xml format,
@XmlRootElement(name = "test") @XmlType
I thought that the method on the controller side would automatically return it just by adding the above annotation, but it seems that it is only in JSON format, if you want to make it in XML format,
It seems that it is necessary to add the setting.
The usage of POJO was subtle, so I fixed it.
(Added on 2018/02/16)
If you are nesting XML or setting the display method of XML tags in detail,
It seems that it is necessary to write a description about JAXB of the site of here.
In the return value of each controller (because I wanted to include arbitrary HttpStatus), I wrote something like
ResponceEntity <Bean that I want to convert to XML>.
Set the return value to
StringWriter sw = new StringWriter(); JAXB.marshal(BeanToXMLClass,sw); return ResponceEntity<>(sw.toString(), HttpStatus.OK);
By giving it like You have successfully passed the converted XML string and status code: 200.