0

这里有一个应用程序,它使用 @JsonViews 来操作来自 web 服务的实体的 json 输出。

public class Customer implements Serializable {

@Id
@JsonView(ListView.class)
private String customerID;

@NotNull
@Size(min = 3)
@JsonView(DetailView.class)
private String companyName;

网络服务方法:

    @POST
// also tested but not working with @JsonView(DetailView.class)
public Customer updateCustomer(Customer customer) {
    return customerService.updateCustomer(customer);
}

在 Wildfly 8 和 9 中一切正常,但在 Wildfly 10 上,当我们发布客户时,“客户”对象只有“空”值。当我从客户对象中删除“@JsonViews”时,将正确使用没有任何 jsonview 的属性。

任何想法为什么 Wildfly 10 具有与以前版本相同的行为以及如何修复它?

非常感谢

PS:带有 JSONViews 的 GET 请求按预期工作

@GET
@JsonView(DetailView.class)
public Customer getCustomerById....
4

1 回答 1

0

自 Jackson 2.5 起允许使用 @JSONView 进行反序列化。如果数据模型使用 JSONView 似乎您必须声明要在发布/放置时使用的 json 视图,但在参数级别:

@POST
public Customer updateCustomer( @JsonView(DetailView.class) Customer customer) { ...

Wildfly 9 正在使用 Jackson 2.4.X = JSONView 不支持反序列化,所以在这里它按我的预期工作。

于 2016-05-30T14:12:32.763 回答