spring boot 返回xml数据格式

    xiaoxiao2021-04-13  35

    在很早之前基本上接口都是xml的风格,最近几年都是json比较流行,格式简洁明了,传输效率高。

    spring boot中加了@RestController后默认返回的数据格式就是json,但是如果我们需要返回xml的格式怎么办,总不能手动转成xml后再返回吧,能不能像json一样自动转,不需要程序关心呢。

    我们只需要加入一个包即可

    <dependency> <groupId>com.fasterxml.jackson.jaxrs</groupId> <artifactId>jackson-jaxrs-xml-provider</artifactId> <version>2.5.0</version> </dependency>
    转载请注明原文地址: https://ju.6miu.com/read-668326.html

    最新回复(0)