I have the below setup in my Spring Boot app:
@RestController
@RequestMapping ("/main/**")
class Child extends Parent {
// Child code
}
abstract class Parent {
// Other code
@RequestMapping ("/sub/**")
public ResponseEntity handle(RequestEntity re) {
// Expected to handle requests with path pattern /main/sub/**
}
The goal is to have the handle() method in abstract Parent Controller to receive all incoming requests for the path pattern "/main/sub/**".
But it's not working. Though it works if I place the handle method (from Parent Controller) inside the Child Controller along with its request mapping.
Can someone help me identify what I'm missing here?
More detailed code below as suggested by Ralf:
@RestController
@RequestMapping ("/main/**")
class Child<T> extends Parent<T> {
// Child code only overrides those methods defined in the parent, and has no request mapping for any method within this class. And it does not override the handle() method defined in parent.
}
abstract class Parent<T> {
// Other code
@RequestMapping ("/sub/**")
public @ResponseBody ResponseEntity<?> handle(RequestEntity<T> re) {
// Expected to handle requests with path pattern /main/sub/
}
}