I have a controller uri hierarchy similar to the example below.
@RequestMapping(value="company/{id}")
public abstract class BaseCompanyController
{
// variety of helper methods, protected autowired objects
}
@Controller
@RequestMapping(value = "company/{id}/documents")
public class DocumentsController extends BaseCompanyController
{
// document controller methods
@RequestMapping(value="something",.... etc)
public void doSomething(){}
}
@Controller
@RequestMapping(value = "company/{id}/financials")
public class FinancialsController extends BaseCompanyController
{
// financials controllers methods
}
What I want to do is to define some code to execute before any handler method in any child controllers. For example I would like to run some code before the doSomething method is called on the DocumentsController. The things I want to do are unique for a specific URI hierarchy.
If I use an interceptor to execute before the handler methods how do I extract the URI parameters from the URI such as the company id from /company/{id}? I really don’t want to pares the URL’s by hand?
Can an interceptor be narrowed down with a URI such as /company/{id} do interceptor mappings understand URI templates?
You can use interceptors only for certain URIs using
<mvc:mapping/>andpathattribute for each one:Reference here.