<legend id='UeJV1'><style id='UeJV1'><dir id='UeJV1'><q id='UeJV1'></q></dir></style></legend>
  1. <tfoot id='UeJV1'></tfoot>
    <i id='UeJV1'><tr id='UeJV1'><dt id='UeJV1'><q id='UeJV1'><span id='UeJV1'><b id='UeJV1'><form id='UeJV1'><ins id='UeJV1'></ins><ul id='UeJV1'></ul><sub id='UeJV1'></sub></form><legend id='UeJV1'></legend><bdo id='UeJV1'><pre id='UeJV1'><center id='UeJV1'></center></pre></bdo></b><th id='UeJV1'></th></span></q></dt></tr></i><div id='UeJV1'><tfoot id='UeJV1'></tfoot><dl id='UeJV1'><fieldset id='UeJV1'></fieldset></dl></div>

        <bdo id='UeJV1'></bdo><ul id='UeJV1'></ul>

      <small id='UeJV1'></small><noframes id='UeJV1'>

      在 web.xml 中引用环境变量

      Referencing Environment Variables in web.xml(在 web.xml 中引用环境变量)

      <small id='WIXjX'></small><noframes id='WIXjX'>

      <legend id='WIXjX'><style id='WIXjX'><dir id='WIXjX'><q id='WIXjX'></q></dir></style></legend>

        1. <tfoot id='WIXjX'></tfoot>
          <i id='WIXjX'><tr id='WIXjX'><dt id='WIXjX'><q id='WIXjX'><span id='WIXjX'><b id='WIXjX'><form id='WIXjX'><ins id='WIXjX'></ins><ul id='WIXjX'></ul><sub id='WIXjX'></sub></form><legend id='WIXjX'></legend><bdo id='WIXjX'><pre id='WIXjX'><center id='WIXjX'></center></pre></bdo></b><th id='WIXjX'></th></span></q></dt></tr></i><div id='WIXjX'><tfoot id='WIXjX'></tfoot><dl id='WIXjX'><fieldset id='WIXjX'></fieldset></dl></div>
              <tbody id='WIXjX'></tbody>
              • <bdo id='WIXjX'></bdo><ul id='WIXjX'></ul>
              • 本文介绍了在 web.xml 中引用环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在预打包一个 JSP Web 应用程序,它依赖于 web.xml 中的一些文件路径设置.这些设置在打包时是未知的,因为它们引用了客户在部署整个应用程序时将设置的路径(其中 web-app 是一个管理界面).

                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 customer will set when deploying the entire application (of which the web-app is a management interface).

                似乎在我的安装程序脚本中避免令牌和文件修改的最简单方法是询问用户安装位置,将此位置设置为环境变量(例如 JAVA_HOME),并让 web.xml 始终引用该位置变量.

                It seems that the easiest way to avoid tokens and file modifications in my installer script, is to ask the user for an install location, set this location as an environment variable (e.g JAVA_HOME), and have web.xml always reference that variable.

                有没有办法从 web.xml 中引用环境变量值?谷歌搜索导致从 ejb xml 文件中设置环境变量的 J2EE 方法.这不是我要找的.

                Is there a way to reference an environment variable value from within web.xml? Google searches lead to the J2EE method of SETTING environment variables from ejb xml files. This is not what I'm looking for.

                推荐答案

                您可以在任何 tomcat xml 配置文件中使用 Ant 样式的变量替换,例如:

                You can use Ant-style variable substitution in any of the tomcat xml config files, such as:

                <servlet-mapping>
                    <servlet-name>mvc-dispatcher</servlet-name>
                    <url-pattern>${foo}</url-pattern>
                </servlet-mapping>
                

                其中 foo 是 Java 系统属性(系统属性).

                Where foo is a Java System Property (sysprop).

                您不能直接使用 OS 环境变量 (envvars),我认为...

                You can't use OS Environment Variables (envvars) directly, I think...

                要使用envvars,你可以把

                To use envvars, you can put

                set "CATALINA_OPTS=-DsomeJavaSysProp=%SOME_OS_ENVVAR%"
                

                bin/setenv.bat 中(或类似地在 bin/setenv.sh 中用于 *nix).您可能需要创建该文件.Tomcat 启动时会运行这个文件.

                in bin/setenv.bat (or similarly in bin/setenv.sh for *nix). You may need to create that file. Tomcat will run this file when it starts.

                由于 CATALINA_OPTS 是一个环境变量(与命令行选项相反),它不应该被系统上的其他用户看到(保存古老的 Unix),尽管我没有对此进行测试.

                As CATALINA_OPTS is an envvar (as opposed to a command line option), it should not be visible by other users on the system (save ancient Unixes), though I haven't tested this.

                http://tomcat.apache.org/tomcat-7.0-doc/config/

                如果你使用 Spring,你可以创建一个 <context:property-placeholder/> bean,然后在 Spring XML 配置文件中直接使用 envvars 或 sysprops(虽然不是 web.xml).

                If you are using Spring, you can create a <context:property-placeholder/> bean and then directly use envvars or sysprops in Spring XML config files (though not web.xml).

                这篇关于在 web.xml 中引用环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Maven JAVA_HOME environment variable is not defined correctly, but it is(Maven JAVA_HOME 环境变量未正确定义,但它是)
                Java System Environment Variable(Java 系统环境变量)
                Java -classpath option(Java -classpath 选项)
                Read environment variable in SpringBoot(在 SpringBoot 中读取环境变量)
                Tomcat 8 - context.xml use Environment Variable in Datasource(Tomcat 8 - context.xml 在数据源中使用环境变量)
                Issue with JAVA_HOME(JAVA_HOME 的问题)
                <tfoot id='TMxu0'></tfoot>
                      <bdo id='TMxu0'></bdo><ul id='TMxu0'></ul>

                            <tbody id='TMxu0'></tbody>
                        1. <small id='TMxu0'></small><noframes id='TMxu0'>

                          <legend id='TMxu0'><style id='TMxu0'><dir id='TMxu0'><q id='TMxu0'></q></dir></style></legend>

                        2. <i id='TMxu0'><tr id='TMxu0'><dt id='TMxu0'><q id='TMxu0'><span id='TMxu0'><b id='TMxu0'><form id='TMxu0'><ins id='TMxu0'></ins><ul id='TMxu0'></ul><sub id='TMxu0'></sub></form><legend id='TMxu0'></legend><bdo id='TMxu0'><pre id='TMxu0'><center id='TMxu0'></center></pre></bdo></b><th id='TMxu0'></th></span></q></dt></tr></i><div id='TMxu0'><tfoot id='TMxu0'></tfoot><dl id='TMxu0'><fieldset id='TMxu0'></fieldset></dl></div>