SpringBoot Controller类接收多个List对象的解决办法

发送的参数:

{"id":1,

"shiftDetails":[{"id":1,"lineId":2}],

"broadcasts":[{"id":1,"lineId":1,"imgPath":"TEST1"},

              {"id":2,"lineId":2,"imgPath":"TEST2"}]

}

Controller类:

@Controller

@RequestMapping("/travelLine")

public class TravelLineController {

    @RequestMapping("/insertTest")

    @ResponseBody

    public Json insertTest(@RequestBody TravelLineDomain tl) {

        Json j = new Json();

        j.setData(tl);

        return j;

    }

}

TravelLineDomain实体类:

@Table(name = "t_travel_line")

public class TravelLineDomain{

    @Id

    @GeneratedValue(generator = "JDBC")

    private Integer id;

    private List shiftDetails;


    private List Broadcasts;

    public Integer getId() {

        return id;

    }

    public void setId(Integer id) {

        this.id = id;

    }

    public List getShiftDetails() {

        return shiftDetails;

    }

    public void setShiftDetails(List shiftDetails) {

        this.shiftDetails = shiftDetails;

    }

    public List getBroadcasts() {

        return Broadcasts;

    }

    public void setBroadcasts(List broadcasts) {

        Broadcasts = broadcasts;

    }

}

有问题可留言哦,看见会第一时间回复!

你可能感兴趣的:(SpringBoot Controller类接收多个List对象的解决办法)