How it works...

Because of the @ComponentScan of the WebApplicationContext, all classes having @Controller will be detected by DispatcherServlet and recognized as controllers during bootstrap. Afterwards, the servlet will search for the controller's URL through the @RequestMapping annotations. In the implementation of our simple controller, the mapping of the URL is done only at the class level. This URL will be invoked by user requests and will eventually tell the servlet what controller to execute. Since there is no other URL mapping in the controller's blueprint, the DispatcherServlet will stop the search and continue identifying the HTTP methods sent by the request to each request handler's @RequestMapping attribute method.

When the client invoked https://localhost:8443/ch03/simple.html through a GET transaction (that is, the hyperlink triggers a GET request), the handler method processGetReq() will be executed by the servlet since it is mapped to RequestMethod.GET. But when a POST form transaction is invoked, the processPostReq() method will be chosen by the DispatcherServlet because it is mapped to the POST method.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.181.36