2013-02-11 29 views
2

我想從.jar歸檔文件中爲我的.html網站提供服務,而不是從文件夾提供服務。 目前我使用的灰熊(含球衣)和服務於靜態頁面,如:html服務器grizzly +球衣(.jtml歸檔文件中的.html)

HttpServer webServer; 
.... 
.... 
webServer.getServerConfiguration().addHttpHandler(new StaticHttpHandler("varwww"), "/app"); 
webServer.start(); 

有沒有辦法讓Web服務器不從文件夾「varwww」檢索.html和從myhtml.jar得到它?

回答

3

此功能在Grizzly 2.3.3+中實現。這裏是記者issue

您可以使用特殊的CLStaticHttpHandler並傳遞ClassLoader來查找靜態資源。例如:

httpServer.getServerConfiguration().addHttpHandler(
      new CLStaticHttpHandler(new URLClassLoader(new URL[] {new URL("file:///home/username/staticfiles.jar")})), "/www"); 

希望這會有所幫助。

+0

請你看看我的灰熊問題:http://stackoverflow.com/questions/35123194/jersey-2-render-swagger-static-content-correctly-without-trailing-slash – DerekY 2016-02-24 06:50:08

相關問題