簡體   English   中英

使用GlassFish 3中glassfish-web.xml的context-root

[英]Using the context-root from glassfish-web.xml in GlassFish 3

我們最近切換到Glassfish 3.1.2.2並將幾個Web應用程序打包為war文件。 有時,這些應用程序的所需上下文根與文件名不同。

回到我們使用Weblogic時,我們通過在weblogic.xml中聲明context-root來實現這一點

<context-root>path/to/our/App</context-root>

我們注意到glassfish-web.xml中存在相同的Tag。 但無論我們在那里定義什么,服務器總是將文件名確定為context-root。

現在我們在asadmin實用程序中找到了選項--contextroot,它允許我們在部署時覆蓋文件名,但我們更願意直接在存檔本身中定義它,以便最終部署它的人不會需要知道所需的contex-root。

有沒有辦法實現這個目標?

在GlassFish 3和GlassFish 4中,Web應用程序的配置通過glassfish-web.xml 在您的情況下,所需的配置文件將如下所示:

<!DOCTYPE glassfish-web-app PUBLIC 
    "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN"
    "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/path/to/our/App</context-root>
</glassfish-web-app>

您可以在“ Oracle GlassFish Server應用程序部署指南”的 GlassFish Server部署描述符文件部分中找到更多詳細信息。 有關此文檔的在線版本,請訪問http://docs.oracle.com/cd/E18930_01/html/821-2417/

通常這應該與glassfish-web.xml如下所示:

<!DOCTYPE glassfish-web-app PUBLIC 
    "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN"
    "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
    <context-root>/path/to/App</context-root>
</glassfish-web-app>

但是在這里看起來你需要一個名為sun-web.xml的文件來完成你的任務。

這是一個例子:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC 
     "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN"   
     "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
    <context-root>/path/to/our/App</context-root>
</sun-web-app>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM