1

I defined an environment variable in web.xml as below..

<env-entry> <env-entry-name>appName</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>myApp</env-entry-value> </env-entry> 

Now I want to access this value in spring mvc resources tag as below.

<mvc:resources order="-10" mapping="/robots.txt" location="${jboss.home.dir}/${appName}/robots.txt" /> 

But the variable ${appName} is not resolving. Can you please help me out on how to read the environment entry in spring xml files?

9
  • possible duplicate of Read an environment variable from applicationContext.xml Commented Jan 13, 2015 at 4:43
  • Which version of Spring are you using? Commented Jan 13, 2015 at 6:36
  • @ankur-singhal - I saw the post. It suggests to define JNDI lookup and refer the JNDI entry. But I am looking for a solution where I can access the variable like JBOSS environment properties -- ${jboss.home.dir}.. Commented Jan 13, 2015 at 8:34
  • @M.Deinum - I am using spring 3.2.9 version. Commented Jan 13, 2015 at 8:34
  • Your question states clearly that yuo want the ${appName} resolved so which is it? Make sure you have a <context:property-placeholder /> in your configuration. You don't need to load a file but you need it for placeholder replacement, especially for those not in the system properties or system environment. Commented Jan 13, 2015 at 8:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.