首页 >> 软件 >> springboot(九)自定转换器messageConverters返回XML格式数据

springboot(九)自定转换器messageConverters返回XML格式数据

2024-01-15 软件

1.导入jackson XML依赖

gradle:

compile group: ‘com.fasterxml.jackson.dataformat’, name: ‘jackson-dataformat-xml’, version: ‘2.9.6’

men:

com.fasterxml.jackson.dataformat jackson-dataformat-xml 2.9.6

2.插件WebMvcConfig,并实现extendMessageConverters方法package com.zqw.springboot.learn.boot.config;import org.springframework.context.annotation.Configuration;import org.springframework.http.converter.HttpMessageConverter;import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;import ja.util.List;@Configurationpublic class WebConfig implements WebMvcConfigurer { @Override public void extendMessageConverters(List> converters) { converters.set(0, new MappingJackson2XmlHttpMessageConverter()); }}

源码IP:

GitHub - zhuquanwen/bootlearn2018

肠胃绞痛
拉肚子拉水怎么办
胃肠型感冒可以喝藿香正气液吗
新冠药物有哪些药
软组织挫伤很疼怎么办
友情链接