samedi 7 mars 2015

Call a resource method of a Controller from within another

This is related to the question: is it possible to call one jax-rs method from another? but in terms of Spring-Boot.


Is it possible to call a resource method of a Controller from within another resource method of an another Controller ?


So, if I have 2 controllers:



@RestController
@RequestMapping("/foo")
public class FooController {

@Path("bar")
public BarController printBarVersion() {

}
}

@RestController
@RequestMapping("/taz")
public class BarController {

@RequestMapping("print")
public static void getBarVersion() {
System.out.println("Version 1");
}
}


Is it possible to call getBarVersion from within printBarVersion method ? What would the URL look like in that case ?


Aucun commentaire:

Enregistrer un commentaire