2012-01-06 7 views
1

GlassFish Serverオープンソース版3(Java EE 6)を実行しています。 Webアプリケーションのデプロイメントのために記述子ファイル "sun-web.xml"を設定しようとすると、問題が発生します。 http://localhost:8080/MyWebApplication/を開くと、従来の "index.jsp"ではなく、ウェルカムページとしてサーブレットを表示したいと考えています。ウェルカムページの代わりにサーブレットを実行するために、GlassFishでデプロイメント記述子を設定するにはどうすればよいですか?

誰かが助けることができますか?

+1

サーブレットURLマッピングで指定されたサーブレットの同一パスを与えることcarefuleうあなたは、プレーンweb.xmlにそれを行うことができます。 –

+0

ありがとう、これは動作します! – nebulus

答えて

2

WebContent/WEB-INF /フォルダにweb.xmlファイルを作成する必要がありました。

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> 
    <servlet> 
     <servlet-name>Index</servlet-name> 
     <servlet-class>server.Index</servlet-class> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Index</servlet-name> 
     <url-pattern>/Index</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
     <welcome-file>Index</welcome-file> 
     </welcome-file-list> 
    <session-config> 
     <session-timeout> 
      30 
     </session-timeout> 
    </session-config> 
</web-app> 
0

web-appのデプロイメント記述子を変更し、ウェルカムファイルリストを変更してサーブレットを指定します。

<!– ==Default Welcome File List========== –> 


When a request URI refers to a directory, the default servlet looks for a “welcome file” within that directory and, if present, to the corresponding resource URI for display. If no welcome file is present, the default servlet either serves a directory listing, or returns a 404 status, depending on how it is configured. 
If you define welcome files in your own application’s web.xml deployment descriptor, that list *replaces* the list configured here, so be sure that you include any of the default values that you wish to include. 



<welcome-file-list> 
<welcome-file>index.html</welcome-file> 
<welcome-file>index.htm</welcome-file> 
<welcome-file>index.jsp</welcome-file> 
</welcome-file-list> 

サーブレットのサーブレットパスを指すように上記の行を変更してください。

/に、MyServlet

</welcome-file-list> 

関連する問題