Using @Value annotation with static final variable in Spring Framework

Annotations are static by their nature, therefore you cannot do it this way.

@Value cannot be used on static fields, but it doesn't matter here - the real problem is that there is no way to use values other than compile time constants as attributes of annotations.

You can use one of the following alternatives:

  • Add a URL rewrite filter (such as this or this) and configure it to perform the necessary conversion.

    This approach looks more elegant due to clear separation of responsibilities - controllers are responsible for doing their jobs, rewrite filter is responsible for obfuscation of URLs.

  • Intercept creation of controller mappings by overriding RequestMappingHandlerMapping. getMappingForMethod() and change their URL patterns at this step (not tested)