朋友,我正在使用Spring数据中的RestController来使用来自外部API的数据 .

当我使用PostMan获取数据时,我得到了这个404错误代码 . 但是如果我在POSTMAN上使用带有 Headers 的直接URL,我会得到正确的数据和响应代码200

请你帮助我好吗

控制台Intelij

2018-11-13 17:30:42.334  WARN 11820 --- [nio-8080-exec-2] o.s.web.servlet.PageNotFound             : No mapping for GET /toto

这是我的控制器类

package com.controller;

    import org.apache.log4j.Logger;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.http.*;
    import org.springframework.web.bind.annotation.CrossOrigin;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RestController;
    import org.springframework.web.client.RestTemplate;

    import javax.json.Json;


    @RestController
    @CrossOrigin("*") // pour gere les erreu d'ente  ex: Orig
    public class FlightRestServives {
        private static Logger logger = Logger.getLogger(FlightRestServives.class.getName());


        @Autowired
        private RestTemplate restTemplate;

        String serviceURL = "https://api.klm.com/opendata/flightoffers/reference-data?country=NL";

        public FlightRestServives() {
        }

        //Consuming a service by GET method
        // @GetMapping("/test")
        @RequestMapping(
                value = "/toto",
                headers = {
                        "api-key=xmc3vburw886j9zqcsfrdu2t",
                        "AFKL-TRAVEL-Country=NL",
                        "AFKL-TRAVEL-Host=KL",
                        "X-Originating-IP=46.193.67.48"}
                /*produces = "application/json",
                consumes = "application/json",
                headers = {
                        "api-key=xmc3vburw886j9zqcsfrdu2t",
                        "AFKL-TRAVEL-Country=NL",
                        "AFKL-TRAVEL-Host=KL",
                        "X-Originating-IP=46.193.67.48"}*/
        )
        public Json getAvailableOperations() {

            logger.debug("Flight");
            HttpHeaders headers = new HttpHeaders();
            headers.add("api-key", "Keyyy");
            headers.add("AFKL-TRAVEL-Country", "NL");
            headers.add("AFKL-TRAVEL-Host", "KL");
            headers.add("X-Originating-IP", "46.193.67.48");

            HttpEntity requestEntity = new HttpEntity(headers);
            logger.debug("request entities  are: " + requestEntity);

            return restTemplate.getForObject(serviceURL, Json.class);
            /*return restTemplate
                    .exchange(
                            serviceURL,
                            HttpMethod.GET,
                            requestEntity,
                            Json.class
                    );*/
        }
    }