@ RequestMapping is placed on the interface, why can springmvc be mapped to its implementation?

springboot
define an interface

public interface HelloController {

 @RequestMapping("/hello")
 String hello();

}

then implement

@ RestController
public class HelloControllerImpl implements HelloController {

 @Override
 public String hello(){
     return "hello";
 }

}

@ RequestMapping should not be inherited by the method in HelloControllerImpl. How does it work?


this is the dynamic proxy for jdk.
spring makes HelloControllerImpl bean when initializing. Then and HelloController as the id number.
calls the hello method of HelloController each time. The hello method of HelloControllerImpl is called through the dynamic proxy of jdk

Menu