applicationpathは動的セグメントをサポートしていないようです。最後に、私たちはsub-resourcesを使用してそれを修正:
コンフィグ
@ApplicationPath("tenants")
public class TenantConfig extends ResourceConfig {
public TenantConfig(ObjectMapper mapper) {
//set provider + add mapper
register(TenantsController.class);
}
}
TenantsController
@Path("/{id}/api")
public class TenantsController {
//register all your controllers including path here
@Path("/somethings")
public Class<SomethingController> something() {
return SomethingController.class;
}
}
SomethingController
@Component
//Don't use @Path, as path info is already defined in the TenantsController
public class SomethingController {
//do your stuff here;
@GET
@Path("/{id}") //Path for this example would be /tenants/{id}/api/somethings/{id}
public JsonApiResult get(@PathParam("id") int id) {
//retrieve one something
}
}
私はあなたが '@ ApplicationPath'にパスパラメータを持つことはできないと思います。 '@Path("/{id}/tenants ")' –
@CássioMazzochiMolin:そうですね、 '@ApplicationPath'内の変数を使うことは、とにかくサポートされていない(私はインターネットでこの問題について何ら言及していない)。 –