将大对象数组发送到Spring Boot Controller并将数据保存在数据库中

时间:2019-03-07 05:15:25

标签: json spring-boot object

我有一个来自角度7的跟随的巨大对象,因此我需要将此对象发布到spring boot app,这意味着从spring boot controller我需要将这些数据保存到数据库中。我应该怎么做?我一点都不知道请帮助我

periodrw = [
    [
      {keyvalue:1, period: 1, day: null , subject :null},
      {keyvalue:2, period: 1, day: "Monday" , subject :null},
      {keyvalue:3, period: 1, day: "Tuesday" , subject :null},
      {keyvalue:4, period: 1, day: "Wednesday" , subject :null},
      {keyvalue:5, period: 1, day: "Thursday", subject :null },
      {keyvalue:6, period: 1, day: "Friday" , subject :null},
    ],
    [
      {keyvalue:1, period: 2, day: null , subject :null},
      {keyvalue:2, period: 2, day: "Monday" , subject :null},
      {keyvalue:3, period: 2, day: "Tuesday" , subject :null},
      {keyvalue:4, period: 2, day: "Wednesday" , subject :null},
      {keyvalue:5, period: 2, day: "Thursday" , subject :null},
      {keyvalue:6, period: 2, day: "Friday" , subject :null},
    ]
  ]

1 个答案:

答案 0 :(得分:0)

将数据以Angular的JSON格式发送,并使用javax.persistence中的percistence注释构建一个具有代表性的java类。反序列化JSON并将其映射到类,最后使用CrudRepository保存它。

此处是漏洞教程:https://www.springboottutorial.com/spring-boot-crud-rest-service-with-jpa-hibernate