I have a spring controller/POJO like this:
@RequestMapping("/foo");
public class MyController {
@RequestMapping("/bar")
public String MyAction() { return someSharedFunc(false); }
@RequestMapping("/debug/ping");
public String MyDebugPing() { return someSharedFunc(true); }
private String someSharedFunc(boolean debug) {
if(debug) return "FooBar"; else return "Debug!";
}
}
In this scenario, the URL for MyDebugPing is /foo/debug/ping. However, I want it to be /debug/ping, effectively ignoring the RequestMapping on the class.
Is that possible?
Just remove the
@RequestMappingannotation from the class and use full paths per individual methods. E.g.If there is a lot of methods then you can simply move out the method to another controller.