![Mastering Spring 5.0](https://wfqqreader-1252317822.image.myqcloud.com/cover/64/36701064/b_36701064.jpg)
上QQ阅读APP看书,第一时间看更新
Model 2 Front Controller architecture
In the basic version of Model 2 architecture, the requests from the browser are handled directly by different servlets (or Controllers). In a number of business scenarios, one would want to do a few common things in servlets before we handle the request. An example would be to ensure that the logged-in user has the right authorization to execute the request. This is a common functionality that you would not want to be implemented in every servlet.
In Model 2 Front Controller architecture, all requests flow into a single controller called the Front Controller.
Picture below represents typical Model 2 Front Controller architecture:
![](https://epubservercos.yuewen.com/9A5966/19470407701638406/epubprivate/OEBPS/Images/8afb2351-2192-4dac-8589-b197a1ff401b.png?sign=1739521434-2XLc3smzcuyG2sypCo7EnTHxcS3hcP1u-0-fb029cbed76b28fe8090b5422d5de438)
The following are some of the responsibilities of a typical Front Controller:
- It decides which Controller executes the request
- It decides which View to render
- It provides provisions to add more common functionality
- Spring MVC uses an MVC pattern with Front Controller. The Front Controller is called DispatcherServlet. We will discuss DispatcherServlet a little later.