有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Tomcat7中的java是否需要复制上下文。将xml转换为conf/Catalina/locahost以使其生效

刚刚从Tomcat6迁移到Tomcat7,注意到当您部署一个名为widget的webapp时,META-INF/context会发生变化。xml不再被复制到conf/Catalina/localhost/widget。xml

我不清楚的是,它是否需要,将根据上下文设置。如果保留在META-INF中,则可以使用xml,或者它们仅在移动到conf/Catalina/localhost/widget时才有效。xml

我使用的是普通的Tomcat7安装


共 (2) 个答案

  1. # 1 楼答案

    据我所知,这是背景。META-INF中使用xml,除非元素deployXML被设置为false。注意Tomcat 7 docs中的默认值是true,除非启用了安全管理器

    然而,从文档中,我的印象是在上下文中设置copyXML属性。xml本身(不接触server.xml)会导致文件被复制到conf:

    <Context antiJARLocking="true" path="/widget" copyXML="true" />
    

    然而,使用Tomcat 7,文件似乎不会被复制到conf,除非在上面Frank回答的问题上copyXML被设置为true

  2. # 2 楼答案

    documentation(我的重点):

    Individual Context elements may be explicitly defined:

    • In an individual file at /META-INF/context.xml inside the application files. Optionally (based on the Host's copyXML attribute) this may be copied to $CATALINA_BASE/conf/[enginename]/[hostname]/ and renamed to application's base file name plus a ".xml" extension.

    关于Host的文档在copyXML上说:

    Set to true if you want a context XML descriptor embedded inside the application (located at /META-INF/context.xml) to be copied to xmlBase when the application is deployed. On subsequent starts, the copied context XML descriptor will be used in preference to any context XML descriptor embedded inside the application even if the descriptor embedded inside the application is more recent. The flag's value defaults to false. Note if deployXML is false, this attribute will have no effect.