Spring-boot return json and xml from controllers

前端 未结 8 1495
Happy的楠姐
Happy的楠姐 2020-12-16 12:05

I have a spring-boot 1.1.7 application that uses Thymeleaf for much of the UI, so the response from my controllers hasn\'t really been a concern. However, now I need to pro

8条回答
  •  旧巷少年郎
    2020-12-16 12:30

    It is very simple Just add jackson-dataformat-xml dependency in your pom.xml file after that your project is able to handle xml/json request or response . add

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

    dependency and add headers content-type or accept as per your need spring boot will handle request or response in json/xml. For full article visit : How to handle xml/json in spring boot

提交回复
热议问题