html服务器grizzly + jersey(.jtml来自.jar档案) [英] html server grizzly+jersey (.html from .jar archive)

查看:77
本文介绍了html服务器grizzly + jersey(.jtml来自.jar档案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从.jar存档而不是文件夹中提供我的.html网站。
目前我使用grizzly(带平针织)并提供静态页面,如:

I want to serve my .html sites from a .jar archive and not from a folder. At the moment i use grizzly (with jersey) and serve static pages like:

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

有没有办法让网络服务器不从文件夹varwww中检索.html并获取来自myhtml.jar?

Is there a way to get the webserver not to retrieve .html from folder "varwww" and to get it from myhtml.jar?

推荐答案

此功能在Grizzly 2.3.3+中实现。以下是通讯员问题

This feature is implemented in Grizzly 2.3.3+. Here is the correspondent issue.

您可以使用特殊的CLStaticHttpHandler并传递ClassLoader来用于查找静态资源。例如:

You can use special CLStaticHttpHandler and pass ClassLoader to be used to find static resources. For example:

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

希望这会有所帮助。

这篇关于html服务器grizzly + jersey(.jtml来自.jar档案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆