思沃讲堂:Spring MVC 实战
[slide]
Th Wo - Bookshelf
by Jimmy Lv
[slide]
MVC Workshop
[slide]
Step 0:
GET: hello {name}!
via Spring Web MVC DispatcherServlet.
[slide]
Step 1:
// given
GET: show all books in index page.
// when
// then
implement fetch book details
functionality.
[slide]
Step 2:
// given
a ready-to-wear form
for book information.
// when
// then
implement create new book
functionality.
[slide]
Step 3:
Edit / Delete / …
[slide]
Extendibility
- What’s Spring IoC & DI?
- Service interface => different implementation
- Data Repository => using different database
- Split front-end & back-end => return data with JSON format
[slide]
作业
- 先把书架 CURD 的功能,使用后端 MVC的形式完善。
- 当然你可以改用其他模板语言,比如 Jade 什么的,这儿用的是 Thymeleadf。
- 然后再改用JSON 格式返回,而不再需要后端模板。
- 为了前后端分离,😂 以下形式就 Okay: