Dropwizard 版本 1.3.0-rc6
大多数有关提供静态内容的文档都是针对旧版本的,甚至是更新的文档掉落向导手册 http://www.dropwizard.io/1.3.1/docs/manual/core.html不完全适合我。
我想提供一个静态 html 文件。我已经修改了提供这些资产的结构/路径,但无法在我的环境中完全获得正确的配置。
静态内容位于以下结构下
src/main/
├── java
│ └── org
│ └── com
│ └── query
│
│ ├── rest
│ │ ├── api
│ │ ├── cli
│ │ ├── core
│ │ ├── db
│ │ ├── health
│ │ ├── resources
│ │ ├── tasks
│ │ └── views
│
├── resources
│ ├── META-INF
│ │ ├── bin-license-notice
│ │ │ └── licenses
│ │ └── services
│ └── rest
│ ├── ftl
│ └── mustache
└── webapp
├── WEB-INF
│ └── views
│ └── jsp
└── resources
└── core
├── css
└── js
multiFileUpload.html
在里面src/main/webapp/resources/core
dir,这最终是我想要服务的。然而,这与 Dropwizard 标准不同src/main/resources/assets/
.
我需要扩展构造函数来指定各个 AssetBundles,因为我计划拥有多个实例AssetBundle
。这就是我的应用程序初始化方法中的内容。
@Override
public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
bootstrap.addBundle(new AssetsBundle("/webapp/resources/core/*", "/", null, "/MultiFileUpload.html"));
}
我还在应用程序运行方法中设置了 urlPattern。environment.jersey().setUrlPattern("/rest/*");
我的 config.yml 中的根路径是rootPath:/rest/*
我有一个应该提供 .html 文件的端点。localhost:port/rest/upload/multiFile
我几乎可以肯定这些路径之一是不正确的,但我尝试根据文档示例更改它们,但没有任何运气。