2

In Spring MVC framework, we have annotation@RequestMapping and something like @RequestMapping(value = "mycontroller/fulfill/order/{myOrder}", method = RequestMethod.GET) Is there a way I can actually put all of those value (url) into a config file and manage them there? For example, as you can see this url starts with "mycontroller" (basically all of my controllers start with this variable). If I change this variable in the future, I do not want to change it one by one instead of just changing at one place.

1 Answer 1

3

@RequestMapping annotations support ${string​} placeholders against local properties and/or system properties and environment variables.

You need to create a .properties file. Then have this read by a PropertPlaceholderConfigurer which your have wired in spring. The key (value left of the = is what goes in the ${} placeholder in your annotation. See here for an example.

1
  • How could I actually add this variable in the config or build.xml? Thanks Jul 27, 2016 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.