{title:'Java Method Return Types', updated:'9.0.0'}

The return type of the Java method can be any serializable POJO as defined in {@doc jm.PojoCategories POJO Categories}. It can also be void if the method is not sending any output (e.g. a request redirect) or is setting the output using the {@link oajr.RestResponse#setContent(Object)} method.

Example:

| @RestGet | public String doGet() { | return "Hello World!"; | }

In addition to POJOs, the following return types are also supported:

REST Java methods can also generate a response via the following:

Example:

| // Equivalent method 1 | @RestGet("/example1/{personId}") | public Person doGet1(@Path("personId") UUID personId) { | Person person = getPersonById(personId); | return person; | } | | // Equivalent method 2 | @RestGet("/example2/{personId}") | public void doGet2(RestResponse res, @Path("personId") UUID personId) { | Person person = getPersonById(personId); | res.setContent(person); | }

Additional parameter types can be defined by overriding {@link oajr.RestContext.Builder#createResponseProcessors(BeanStore,Supplier)}.