2. BookController 클래스에 다음 내용을 작성합니다.
코드 4-8 BookMarket/src/main/java/com/springmvc/controller/BookController.java
package com.springmvc.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.springmvc.domain.Book;
import com.springmvc.service.BookService;
@Controller
public class BookController {
@Autowired
private BookService bookService; ➊
@RequestMapping(value="/books", method=RequestMethod.GET) ➋
➌
public String requestBookList(Model model) {
List<Book> list = bookService.getAllBookList();
model.addAttribute("bookList", list); ➍
return "books"; ➎
}
}