Trouble using URL templates and @RequestMapping in handler methods

Hi Dev’s I am working on the OAuth2 module and trying to display a page to view/edit details of a registered app. I have a Controller method defined as follows https://github.com/maany/openmrs-module-oauth2-prototype/blob/02954f126ea5ead147641d1a0d1dc3326d772479/omod/src/main/java/org/openmrs/module/oauth2/web/controller/ClientListController.java

It contains a method @RequestMapping**(value = “application/{clientId}”)** public String showClientDetails(@PathVariable(“clientId”) Integer clientId, ModelMap model) { … return “/module/oauth2/registration”; } When I send a URL : localhost:8080/openmrs/module/oauth2/application/2 or any integer I get a HTTP 404 error and the following message : The page “/openmrs/module/oauth2/application/2” cannot be found. Check the link and try again.

Could you point me in the right direction to resolve this?

Here is the screenshot of the 404 error screen

//cc @harsha89 @surangak

1 Like

How about using URL Params? You may define url mappings via application context file or use standard mappings.

Hey @maany , I think its a similar issue in my module too:

I included the prop keys and the beans related to the controllers RoleListController and RoleFormController.

Hope it helps :smile:

I haven’t implemented successfully completely though, this part of the xml work is right I believe :smiley:

At a glance, I suspect that the * in your class-level RequestMapping is the problem. My understanding is that the RequestMapping value from the class and the method are just concatenated together so you’re ending up with a RequestMapping for “/module/oauth2/*application/{clientId}”, but you actually want to get rid of the * so you get “/module/oauth2/application/{clientId}”

Here is an example from the REST Web Services module that uses class-level + method-level RequestMappings, along with a PathVariable