1
一段代碼,像這樣的問題:一個關於Spring控制器
@Controller
public class HomeController {
public static final int DEFAULT_SPITTLES_PER_PAGE = 25;
private SpitterService spitterService;
@Inject
public HomeController(SpitterService spitterService) {
this.spitterService = spitterService;
}
@RequestMapping({"/","/home"})
public String showHomePage(Map<String, Object> model) {
model.put("spittles",
spitterService.getRecentSpittles(DEFAULT_SPITTLES_PER_PAGE));
return "home";
}
}
我困惑是servlet知道什麼傳遞的方法?在這個例子中,它將一個Map模型傳遞給showHomePage,我想知道模型的來源以及模型中包含哪些內容?
該方法不需要將模型傳遞給視圖,servlet會隱式地將參數模型傳遞給視圖?
謝謝,我現在明白了。 – user748554