【问题标题】:RestEasy-post-method with abstract param带有抽象参数的 RestEasy-post-method
【发布时间】:2015-01-30 12:28:47
【问题描述】:

我有一个在 wildfly 8 上运行的 resteasy 网络服务。post 方法使用内容类型 json。使用普通对象作为参数,它工作正常。但是如果参数是我得到的接口

问题:抽象类型要么需要映射到具体类型,要么需要自定义反序列化器,要么需要使用额外的类型信息进行实例化

如何告诉 resteasy 将接口类型映射到特定实现?

这里实现webservice方法:

@POST
@Path("/test")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response signUpJson(ObjInterface obj) {
    Response.ResponseBuilder builder;
    // do something
    builder = Response.ok();
    return builder.build();
}

【问题讨论】:

    标签: json parameters interface jax-rs resteasy


    【解决方案1】:

    创建并注册MessageBodyReader,更多信息请点击此处:https://jersey.java.net/documentation/latest/message-body-workers.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-26
      • 2014-05-30
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      • 2012-03-16
      • 1970-01-01
      相关资源
      最近更新 更多