Using properties in web.xml

后端 未结 3 956
一整个雨季
一整个雨季 2020-12-09 20:05

I would like to control the settings in web.xml and using different once for different environments.

Is it possible to use a property, from a property file on classp

3条回答
  •  青春惊慌失措
    2020-12-09 20:51

    AFAIK context-param and env-entry both hold static values. You will not get the runtime (dynamic) value from the property file. It will be like:

         
      myparam     
      myactualpropertyvalue     
     
    

    Any change to the value needs a redeployment of the web app.

    In your example, the value you retrieve would be the String classpath:mypropertyfile.properties['myproperty']

    If you use Glassfish you can update it on the fly from commandline http://javahowto.blogspot.com/2010/04/glassfish-set-web-env-entry.html

    If I understand your requirement is at build time (i.e different war for different env) and not during running time?

    You could replace the values in web.xml as part of the ant/maven build process.

提交回复
热议问题