Spring mvc query matching conventions

I am trying to come up with a good agreement to do query mappings in my application

right now I have

RegistrationController {
   @RequestMapping(value="/registerMerchant")
   ...
   @RequestMapping(value="/registerUser")
   ...
}

but this is not ideal, because when looking at the URL you may not know to look RegistrationControllerfor the code.

Is there a way that I can programmatically add a controller name from these mappings creating them:

/registration/registerMerchant
/registration/registerUser
+5
source share
2 answers

Not programmatically, but this kind of template that I saw works:

@Controller
@RequestMapping(value="/registration/**")
RegistrationController {
   @RequestMapping(value="**/registerMerchant")
   ...
   @RequestMapping(value="**/registerUser")
   ...
}

Having said that, in the past I have found that it is extremely difficult to work as I expected. This can be done for the job, however.

+8
source

**/ . , URI REST .

@Controller
@RequestMapping("/services")
public class RegistrationController {

    @RequestMapping(value = "/merchant/register")
    public void processMerchantRegistration() {

    }

    @RequestMapping(value = "/user/register")
    public void processUserRegistration() {

    }

}
+4

All Articles