Spring Boot返回XML文

1、pom.xml中加入

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

2、Controller中这么写

package com.example.AdcService.WebService;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "Shipment")
public class ShipmentInterfaceService {

    @GetMapping(value = "ShipmentInterfaceCorrectService",produces = MediaType.APPLICATION_XML_VALUE)
    public String returnCorrectResponseXML(){
        String xml="

 

你可能感兴趣的:(笔记)