简体   繁体   中英

Date is set to null when calling rest service

We have a rest

@POST
@Consumes(MediaType.APPLICATION_JSON)
@Path("save")
public String save(PaycodeDTO dto)

We have a client

public void saveOrUpdateAndPushToMdm(PaycodeDTO paycode) {
    executePost("/services/paycode/save/", Entity.entity(paycode, MediaType.APPLICATION_JSON_TYPE), String.class);
}


 protected <T, S> S executePost(String url, Entity<T> reqBody, Class<S> returnClass) {
     Response resp = executeRequest(getTarget()
                .path(url)
                .request(MediaType.APPLICATION_JSON_TYPE)
                .accept(MediaType.APPLICATION_JSON_TYPE))
                .post(reqBody);

and the dto :

@XmlRootElement
public class PaycodeDTO implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long id;
    private String name;
    private boolean isDeleted;
    private Date validFrom;
    private Date validUntil;

with getters and setters.

We fill validFrom and validUntil before calling the rest, but then the call reaches rest validFrom is null, validUntil is null.

What is the problem ?

The rest uses jersey-spring3. version 2.22.1

我需要注册JacksonJaxbJsonProvider.class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM