美文网首页
SpringBoot Controller类接收多个List对象

SpringBoot Controller类接收多个List对象

作者: zhouzilin | 来源:发表于2018-12-02 16:05 被阅读0次

发送的参数:

{"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<ShiftDetailDomain> shiftDetails;

    private List<BroadcastDomain> Broadcasts;

    public Integer getId() {

        return id;

    }

    public void setId(Integer id) {

        this.id = id;

    }

    public List<ShiftDetailDomain> getShiftDetails() {

        return shiftDetails;

    }

    public void setShiftDetails(List<ShiftDetailDomain> shiftDetails) {

        this.shiftDetails = shiftDetails;

    }

    public List<BroadcastDomain> getBroadcasts() {

        return Broadcasts;

    }

    public void setBroadcasts(List<BroadcastDomain> broadcasts) {

        Broadcasts = broadcasts;

    }

}

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

相关文章

网友评论

      本文标题:SpringBoot Controller类接收多个List对象

      本文链接:https://www.haomeiwen.com/subject/oewjcqtx.html