Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春季Json解组期间的JsonMappingException_Java_Json_Spring_Jackson_Unmarshalling - Fatal编程技术网

Java 春季Json解组期间的JsonMappingException

Java 春季Json解组期间的JsonMappingException,java,json,spring,jackson,unmarshalling,Java,Json,Spring,Jackson,Unmarshalling,这是我的POJO课程: public class OrdineIngressi { private Integer spettacolo; private Integer settore; private Integer pv; private List<OrdineIngresso> ingressi=new ArrayList<OrdineIngresso>(); public OrdineIngressi(Integer

这是我的POJO课程:

public class OrdineIngressi {

    private Integer spettacolo;
    private Integer settore;
    private Integer pv;
    private List<OrdineIngresso> ingressi=new ArrayList<OrdineIngresso>();

    public OrdineIngressi(Integer spettacolo, Integer settore, Integer pv,
            List<OrdineIngresso> ingressi) {
        super();
        this.spettacolo = spettacolo;
        this.settore = settore;
        this.pv = pv;
        this.ingressi = ingressi;
    }



    public OrdineIngressi() {
        super();
    }



    public Integer getSpettacolo() {
        return spettacolo;
    }
    public void setSpettacolo(Integer spettacolo) {
        this.spettacolo = spettacolo;
    }
    public Integer getSettore() {
        return settore;
    }
    public void setSettore(Integer settore) {
        this.settore = settore;
    }   
    public Integer getPv() {
        return pv;
    }
    public void setPv(Integer pv) {
        this.pv = pv;
    }
    public List<OrdineIngresso> getIngressi() {
        return ingressi;
    }
    public void setIngressi(List<OrdineIngresso> ingressi) {
        this.ingressi = ingressi;
    }



    public class OrdineIngresso {

        private Integer tipoingresso;
        private Integer abbonamento;
        private int numero;
        private Integer[] posti;

        public OrdineIngresso() {
            super();
        }



        public OrdineIngresso(Integer tipoingresso, Integer abbonamento,
                int numero, Integer[] posti) {
            super();
            this.tipoingresso = tipoingresso;
            this.abbonamento = abbonamento;
            this.numero = numero;
            this.posti = posti;
        }
        public Integer getTipoingresso() {
            return tipoingresso;
        }
        public void setTipoingresso(Integer tipoingresso) {
            this.tipoingresso = tipoingresso;
        }
        public Integer getAbbonamento() {
            return abbonamento;
        }
        public void setAbbonamento(Integer abbonamento) {
            this.abbonamento = abbonamento;
        }
        public Integer[] getPosti() {
            return posti;
        }
        public void setPosti(Integer[] posti) {
            this.posti = posti;
        }
        public int getNumero() {
            return numero;
        }
        public void setNumero(int numero) {
            this.numero = numero;
        }   


    }   

}
当控制器尝试解组json输入时,我得到以下信息:

nested exception is org.codehaus.jackson.map.JsonMappingException: No suitable constructor found for type [simple type, class com.bean.OrdineIngressi$OrdineIngresso]: can not instantiate from JSON object (need to add/enable type information?)

为什么??有一个默认的构造函数

您就快到了,只需将您的内部类
设置为静态的

...
    public static class OrdineIngresso {
        private Integer tipoingresso;
        ...
    }
IIRC它与非args内部类构造函数实际上不是非args这一事实有关,因此jackson没有实例化这些非静态内部类的通用方式


干杯,

你为什么不用英文名字?…因为我不是英国人。但我认为这里的名字并不重要,认为它像代码混淆;阿达马罗德也许是因为他是意大利人?这有关系吗?我认为火腿真的很重要,而且它们通常是英国人。例如,我无法理解您在代码中使用的对象,因此无法回答您的问题。幸运的是,在这个特殊问题上,您不需要理解(口语)语言就能发现错误。
...
    public static class OrdineIngresso {
        private Integer tipoingresso;
        ...
    }