Announcement Announcement Module
No announcement yet.
Static URL properties, dynamic context root? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Static URL properties, dynamic context root?

    I've defined a number of system-wide properties as servlet context attributes, using Spring's ServletContextAttributeExporter. This works quite well, except with an URL that is based on the context root, like this one:

    <entry key="headerImageURL" value="/myapp/images/someImage.jpg" />

    The problem is that hard-coding the context root, in this case "/myapp", is unacceptable.

    I have cobbled together my own solution, that will iterate over all context attributes after Spring has initialized them, and perform a regex replace on specially-formatted placeholder (which happens to look like an EL expression) a la:

    <entry key="headerImageURL" value="${contextRoot}/images/someImage.jpg" />

    Despite having found a workaround, I suspect that I'm overlooking a simpler way to do this with a Spring feature.

    Thanks in advance, for any suggestions you can provide.