dea*_*mon 6 java jax-rs grizzly
我希望Grizzly从.jar中提供静态文件,其中包含JAX-RS应用程序,Grizzly和所有其他库.我正在使用org.glassfish.grizzly.http.server.StaticHttpHandler静态文件.
public class Main {
// ...
public static void main(String[] args) throws IOException, URISyntaxException {
final HttpServer server = startServer();
server.getServerConfiguration().addHttpHandler(
new StaticHttpHandler(getTemplatePath()), "/static");
System.in.read();
server.stop();
}
private static String getTemplatePath() throws URISyntaxException {
return Main.class.getClassLoader().getResource("templates/static").getPath();
}
}
Run Code Online (Sandbox Code Playgroud)
但是只有我用IDE启动应用程序才有效.如果我打包.jar并运行它,则找不到静态文件.
是否可以使用灰熊来提供.jar中的静态文件StaticHttpHandler?如何?
| 归档时间: |
|
| 查看次数: |
4749 次 |
| 最近记录: |