인프런 커뮤니티 질문&답변
Setter 제거 관련 질문
작성
·
349
0
Setter 를 어떻게 지울까 하다가 이렇게 생성자로 했는데,
이렇게 해도 올바른 방법일까요 ? 아니면 다른 방법이 훨씬 유효할까요..?
생성 메서드를 해보려 했는데 ,
GetMapping 에서 빈 폼을 가져올 때 stockQuantity 와
price 에서 null 땜에 바인딩 미스매치 에러가 뜨더라구요
매개변수에 @Nullable 을 줬는데도 해결이 안되서요
public Book(String author, String isbn, String name, int price, int stockQuantity) {
super(name,price,stockQuantity);
this.author = author;
this.isbn = isbn;
}
public Item(String name, int price, int stockQuantity) {
this.name = name;
this.price = price;
this.stockQuantity = stockQuantity;
}
Book book = new Book(form.getAuthor(),form.getIsbn(),form.getName(),form.getPrice(),form.getStockQuantity());





