더북(TheBook)

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"; 
    } 
}
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.