Hel*_*oem 9 java configuration jetty dropwizard
我正在构建一个单页面应用程序,它在客户端和后端执行所有html请求路由,它使用dropwizard来提供一堆JSON服务.
基本上我无法使用dropwizard中的码头为每个请求提供index.html服务,但以下路径除外:
/css
/i18n
/img
/js
/lib
/services
/templates
Run Code Online (Sandbox Code Playgroud)
事实上,我在查找文档时遇到了很多麻烦,这些文档告诉您如何设置任何http路由.(我不是一个java人).
这是我简单的yaml配置:`
http:
port: 8082
adminPort: 8083
rootPath: /service/*`
Run Code Online (Sandbox Code Playgroud)
我需要添加什么才能实现这一目标.
谢谢
mth*_*ers 14
我这样做了,没有改变我的配置.事实上,它只花了我一行代码,放在initialize我Application班级的方法中:
bootstrap.addBundle(new AssetsBundle("/app", "/", "index.html", "static"));
Run Code Online (Sandbox Code Playgroud)
这基本上是指/app在URL模式下的JAR文件内部提供任何内容/,并将其index.html作为默认文件.此捆绑包将命名为static,但您可以选择您喜欢的任何名称.
请注意,我使用的是Dropwizard的0.7.0-rc2版本,我不确定它是否适用于早期版本.