此規則會標示
Context <Parameter>
在 META-INF/context.xml 檔中找到個元素。
Apache Tomcat 容許
Context <Parameter>
要在下列位置中定義的元素:
- META-INF/context.xml 檔
- Tomcat conf 目錄中的應用程式 XML 配置檔
- 該
<Host>
元素中的 conf/server.xml
這項移轉工具只會移轉 META-INF/context.xml 檔中的參數元素。
定義在其他位置中的 Parameter 資訊可以複製到
META-INF/context.xml 檔,以便處理它。
如果 WEB-INF/web.xml 存在於 Web 專案中:
Context <Parameter>
元素在下列任一情況下會被標記:
- 該項目在 web.xml 檔中沒有相符項。
- 該項目的值與 web.xml 檔中的相符項不同,且其置換旗標設為 false。
自動修正將新增
<context-param>
web.xml 檔案中的 代表
Context <Parameter>
元素,如果它不存在於 web.xml 檔案中。
如果該項目存在,就會更新它。
如果 WEB-INF/web.xml 不存在:
全部
Context <Parameter>
元素將被標記。
自動修復會建立一個 WEB-INF/web.xml 檔案 包括適當的
<context-param>
元素,如果 網頁專案為 Java EE 5 或更高版本。 自動修正程式會報錯,如果網頁專案 為 J2EE 1.4 或更低。
舉例來說,請考量具有下列內容的 META-INF/context.xml 檔:
<參數
description="Trigger because it does not exist"
name="newEntry"
override="false"
value=" abc123 "/>
<Parameter
description="Trigger because of different value"
name="parameter_1"
override="false"
value="new Value"/>
<Parameter
description="Will not trigger because of override set to true"
name="parameter_2"
override="true"
value="123"/>
應用程式含有下列 web.xml 檔:
<context-param
<description>因不同值而觸發</description>
<param-name>parameter_1</param-name>
<param-value>oldValue</param-value>
</context-param>
<context-param>
<description>因為覆寫設定為 true,所以不會觸發</description>
<param-name>parameter_2</param-name>
<param-value>123456789</param-value>
</context-param>
自動修正套用後, web.xml 將更新為 包含:
<context-param
<description>因不存在而觸發</description>
<param-name>newEntry</param-name>
<param-value>abc123</param-value>
</context-param>
<context-param>
<description>因不同值而觸發</description>
<param-name>parameter_1</param-name>
<param-value>新值</param-value>
</context-param>
<context-param>
<description>因為覆寫設定為 true,所以不會觸發</description>
<param-name>parameter_2</param-name>
<param-value>123456789</param-value>
</context-param>
如需 Tomcat 中之環境定義參數的相關資訊,請參閱: