简体   繁体   中英

cannot reach controller method in SpringBoot

I'm new to Spring Boot and I'm playing around with it trying to get a response from my backend.

The web server and application are running without errors but when I try to get "Hello World" by typing localhost:8080/api/hello I get a 404 not found.

This is the controller method

    @RestController
    @RequestMapping("/api")
    public class EmployeeController {


      @GetMapping("/hello")
      public String greeting() {
        return "Hello, World";
      }

   }

This is the response I get

the response

You've defined your api path as api/hello , but based on the screenshot of your request you are calling /hello .

use localhost:8080/api/hello , it will a solution for your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM