the list of objects is not parsed

Viewed 22
const actorForm = {
            firstName: "er",
            lastName: "er",
            patronymic: "er",
            age: "2022-09-10",
            gender: "rge"
        }

         const addMovieForm = {
             title: titleRef.current.value,
             movie: movieFileRef.current.files[0],
             poster: posterFileRef.current.files[0],
             genre: genreRef.current.value,
             rating: ratingRef.current.value,
             yearOfRelease: yearRef.current.value,
             country: countryRef.current.value,
             director: {
                 firstName: directorFirstNameRef.current.value,
                 lastName: directorLastNameRef.current.value,
                 patronymic: directorPatronymicRef.current.value,
                 age: directorYearRef.current.value
             },
             actors:[actorForm, actorForm , actorForm , actorForm],
             plotDescription: plotDescriptionRef.current.value
         }


         axios.post(urlServer.URL_MOVIE_SAVE, addMovieForm, {headers})

this is my javascript code , post a request to the server. maybe there's a mistake here?

@RestController
@RequestMapping("/movie")
public class MovieController {

@PostMapping("/save")
public ResponseEntity<String> saveMovie(@ModelAttribute AddMovieForm addMovieForm){
   System.out.println(addMovieForm.getActors().size());
   return ResponseEntity.ok().build();
}

this is the controller


@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ActorForm {
    private String firstName;
    private String lastName;
    private String patronymic;
    private String age;
    private String gender;
}

this is a list class

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class AddMovieForm {
    private String title;
    private MultipartFile movie;
    private MultipartFile poster;
    private String genre;
    private Float rating;
    private String yearOfRelease;
    private String country;
    private DirectorForm director;
    private List<ActorForm> actors;
    private String plotDescription;
}

when the request is made , the actors field is empty , the list is empty

what could be the problem ? all fields are initialized except the actors field , it is empty

0 Answers
Related