jersey 2.x Moxy json 不支持 POJO 列表

jersey 2.x Moxy json does not support POJO list

我是球衣的新手,而我正在尝试使用 ajax 从 jquery 接收数据到 java 它不映射 pojo。

POJO :-

@XmlRootElement
public class RulesTO {

    private int ruleId;
    private String ruleName;
    private int ruleStudioId;
    private String ruleStudioName;
    private String ruleDescription;
    private Boolean ruleStatus;
    private List<SitesTO> siteRule;
    private List<IspsTO> ispRule;
    private List<CountriesTO> countryRule;
    private String studioDefaultRule;

//getters and setters
}

Ajax :-

var rulesTO = {
                            ruleName : $('#ruleName').val(),
                            ruleStudioId : $('#studios option:selected').attr("stream"),
                            ruleStudioName : $('#studios option:selected').text(),
                            ruleDescription : $('#ruledescription').val(),
                            ruleStatus : false,
                            siteRule : newSiteObject,
                            ispRule : newIspObject,
                            countryRule : newCountryObject,
                            studioDefaultRule : newStudioDefaultObject
                    }

                    $.ajax({
                        url : "/idns/idnsData/saveConfiguration",
                        type : "POST",
                        contentType : "application/json",
                        dataType : "json",
                        data : JSON.stringify(rulesTO),
                        success : function(data){
                            alert("success insert");
                        }
                    }); 

java:-

@Path("/idnsData")
public class IdnsDataHandler {

    private static Logger logger = Logger.getLogger(IdnsDataHandler.class);
    private Connection connection = null;

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/saveConfiguration")
    public RulesTO saveConfiguration(RulesTO rulesTO) throws Exception{
        try{
            logger.info("IdnsDataHandler : saveConfiguration Method start");
            System.out.println("Rule Id : "+rulesTO.getRuleId());
            System.out.println("Rule Name : "+rulesTO.getRuleName());
            System.out.println("Studio Id : "+rulesTO.getRuleStudioId());
            System.out.println("Studio Name : "+rulesTO.getRuleStudioName());
            System.out.println("Rule Description : "+rulesTO.getRuleDescription());
            System.out.println("Rule Status : "+rulesTO.isRuleStatus());
            System.out.println("List Site : "+rulesTO.getSiteRule().size());
            System.out.println("List Isp : "+rulesTO.getIspRule().size());
            System.out.println("List Country : "+rulesTO.getCountryRule().size());
            System.out.println("List studioDefault : "+rulesTO.getStudioDefaultRule());


            List<SitesTO> takeall = rulesTO.getSiteRule();
            for(int i=0;i<takeall.size();i++){
                System.out.println("===="+takeall.get(i).getSiteName());
            }
}
}

output :-
Rule Id : 0
Rule Name : example
Studio Id : 3
Studio Name : MAsia
Rule Description : test
Rule Status : false
List Site : 5
List Isp : 0
List Country : 0
List studioDefault : null

但我想将列表站点对象和值映射到 POJO,但不起作用。请帮助我,这对我的项目非常有用。谢谢

check the dependencies for Moxy json, Thats work for me.

1.jersey-media-moxy-2.13.jar
2.jersey-entity-filtering-2.13.jar
3.org.eclipse.persistence.antlr-2.5.0.jar
4.org.eclipse.persistence.asm-2.5.0-RC2.jar
5.org.eclipse.persistence.core-2.5.0-RC2.jar
6.org.eclipse.persistence.moxy-2.5.0.jar