Skip to content

Mapping Requests to your Controller

Michael Delamere edited this page Aug 4, 2016 · 6 revisions

In this section you will learn how to map different types of request URIs to your request handlers. Whether you are dealing with RESTful type URIs, dynamic URIs with parameters or plain URIs, geeMVC can deal with all these cases. And if you need some very special routing you can even use Javascript, Groovy or MVEL to dynamically map your request handler. Later on we will also show you how to map your request handler depending on cookie, header, http-method or the content-type (application/json, application/xml, ...).

Here are some URI examples that geeMVC can handle:

Plain URIs

/hello/world
/hello-world.html
/home
/index.html
/some/plain/uri

URIs with Parameters

/product/view?productId=12345
/product/view/12345
/delete-product/?id=12345
/product/update/12345
/category/view/12345?sortBy=name
/category/view/12345?sortBy=name&page=3
/category/view/12345/3?sortBy=name

RESTful type URIs

GET /api/v1/products
GET /api/v1/products?offset=40&limit=20
GET /api/v1/products/12345
POST /api/v1/products/12345
PUT /api/v1/products/12345
DELETE /api/v1/products/12345

Find out in the next section how you can register your controller with the @Controller annotation and then how to map your requests with the @Request annotation.

Clone this wiki locally