Referencing Environment Variables in web.xml

前端 未结 7 1235
無奈伤痛
無奈伤痛 2020-11-30 01:37

I\'m pre-packaging a JSP web-app that relies on some file path settings found within web.xml. These settings are unknown at packaging time, because they reference a path the

相关标签:
7条回答
  • 2020-11-30 02:33

    Basically, you don't do it that way. The web.xml should contain default values for things, yes, but you should override them when actually doing the deployment. If you're deploying to Tomcat, you do this by including appropriate entries in the context.xml that you use for the deployment. For example:

    <Context path="/app">
        <!-- For things described by webapp parameters -->
        <Parameter name="foobar" value="grill" />
    
        <!-- For things described by environment entries -->
        <Environment name="Bla/SomeFilePath" type="java.lang.String"
                value="/opt/bla" />
    </Context>
    

    Other containers will have their own mechanisms for doing this so. You'll have to look up their documentation (or make your request for help more focussed).

    0 讨论(0)
提交回复
热议问题