使用 WebSphere 延伸來定義虛擬目錄對映

WebLogic 虛擬目錄對映容許應用程式提供位於應用程式文件根目錄外部的影像或靜態檔案。 您可以使用 WebSphere 檔案提供特性來提供這些檔案。 此規則偵測 <virtual-directory-mapping> 元素是否存在於 weblogic.xml 檔案中。 自動修復將能夠幫助您在 傳統或 相應的 <fileServingAttributes> 元件,在 WebSphere 傳統或 Liberty web 擴充套件檔案中。

例如,weblogic.xml 檔可以包含下列對映:

<virtual-directory-mapping>
<本端路徑>c:/usr/files</本端路徑>
<url-pattern>/images/*</url-pattern>
<url-pattern>*.jpg</url-pattern>
</virtual-directory-mapping>

您可以在 WebSphere Application Server Web 延伸中定義相同的資訊,如下例所示:

<fileServing屬性 xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="c:/usr/files"/>
<fileServing屬性 xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/* *.jpg"/>

extendedDocumentRoot 檔案提供屬性是一個以逗點定界的字串,其中含有多個存在於應用程式 Web 模組外的根目錄。

file.serving.patterns.allow 檔案提供屬性是一個以空格定界的字串,其中含有多個型樣。

如果應用程式在多個位置具有靜態內容,當您從應用程式提供內容時,可能會發生問題。 在 WebLogic 中,任何定義的 virtual-directory-mapping 都可從環境定義根目錄和目錄位置中使用。 在 WebSphere Application Server 中,file.serving.patterns.allow 內容會限制存取在延伸文件根目錄或環境定義根目錄內,符合指定型樣的靜態內容。

根據檔案組織的方式,您可能需要修改 file.serving.patterns.allow 內容值。 例如,

<fileServing屬性 xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="/common/files"/>
<fileServing屬性 xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/*"/>

如果環境定義根目錄下的 /common/files/common/files/images 中有 images 目錄,請將 /common/files/images 新增至 file.serving.patterns.allow 內容值。

<fileServing屬性 xmi:id ="FileServingAttribute_1" name="extendedDocumentRoot" value="/common/files"/>
<fileServing屬性 xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="/images/* /common/files/images/*"/>

您可以使用下例中的設定來允許對檔案有較多的存取權,但使用這項設定可能也會允許比預期多的內容可供應用程式使用。

<fileServing屬性 xmi:id ="FileServingAttribute_2" name="file.serving.patterns.allow" value="*"/>

如需詳細資訊和範例,請參閱下列資源: