当我们发布客户

时间:2016-05-19 09:44:03

标签: json jackson wildfly-10 json-view

这里有一个应用程序,它使用@JsonViews来处理来自webservices的实体的json输出。

public class Customer implements Serializable {

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

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

web服务-方法:

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

所有在Wildfly 8和9中都运行良好,但在Wildfly 10上,当我们发布客户时,“customer”对象只有“null”值。当我从Customer-Object中删除“@JsonViews”时,没有任何jsonview的属性将被正确使用。

任何想法为什么Wildfly 10有另一个表现与以前的版本和如何解决它?

非常感谢

PS:GET请求的GET请求按预期工作

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

1 个答案:

答案 0 :(得分:0)

自Jackson 2.5以来,允许使用@JSONView进行反序列化。 如果datamodel正在使用JSONView,那么你似乎必须声明你想要在post / put时使用的json视图,但是在参数级别是:

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

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