Search code examples
javaspringspring-mvcresourcesspring-el

Spring SpEL not working for <mvc:resources> location parameter


This works:

<mvc:resources mapping="/images/**" location="file:///C:/Temp/" />

This does not work:

<mvc:resources mapping="/images/**" location="#{systemEnvironment['MY_SYS_VAR']}"/>

where MY_SYS_VAR is an environment variable set to "C:/Temp/"

Note: Any variation such as

location="file:///#{systemEnvironment['MY_SYS_VAR']}" 

or

location="#{'file:///' + systemEnvironment['MY_SYS_VAR']}"

doesn't seem to work either.

I think that this is related to https://jira.spring.io/browse/SPR-9291; however, the defect is marked as resolved (fixed), and I am using Spring 3.2


Solution

  • I switched from 3.2.2 to 3.2.8 and it is now working with the spring expression.