I am creating a rest api for one webapp and have encountered a problem with RequestMapping.
Mostly there are users who are grouped in different areas. When they work with the system, some information is stored in an object called "session" and is written to the DB.
I have the following URLs:
1) http://server.com/api/v1/domain/domainName/sessions - shows information about all sessions for all users in the domain.
2) http://server.com/api/v1/domain/domainName/user/userName/sessions - show information about the sessions of a specific user.
I am using spring 3.0.5 and declared 2 handlers in the controller class:
@RequestMapping(value = "/{domainId}/sessions", method=RequestMethod.GET)
public void findSessions(@PathVariable final String domainId) {
...
}
@RequestMapping(value = "/{domainId}/user/{username}/sessions", method=RequestMethod.GET)
public void findUserSessions(
@PathVariable final String domainId,
@PathVariable final String username) {
...
}
: SimpleUrlHandlerMapping + Annotations
SimpleUrlHandlerMapping:
<property name="mappings">
<value>
/api/v1/domain/** = api.DomainsController
</value>
</property>
, URL . URL 2 domainId pathvariable, .
, - .
@RequestMapping(value = "/api/v1/domain/{domainId}/sessions", method=RequestMethod.GET)
@RequestMapping(value = "/api/v1/domain/{domainId}/user/{username}/sessions", method=RequestMethod.GET)