Try   HackMD

ssm整合:查詢書籍功能

tags: ssm整合

1.寫一個BookController

@Controller @RequestMapping("/book") public class BookController { //controller調 service層 @Autowired @Qualifier("BookServiceImpl") private BookService bookService; }

使用@Qualifier注入成功後,就能點選旁邊的綠點,跳到對應的bean

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

完整的BookController

@Controller @RequestMapping("/book") public class BookController { //controller調 service層 @Autowired @Qualifier("BookServiceImpl") private BookService bookService; //查詢全部的書籍,並返回到一個書籍展示頁面 @RequestMapping("/allBook") public String list(Model model){ List<Books> list = bookService.queryAllBook(); model.addAttribute("list",list); return "allBook"; } }