Spring controllers ( @Controller ) allow you to process multiple URL patterns. And what about servlets, one servlet per url ? Thank.

Raised to the main page by a community spirit member yesterday .

This question contains answers that can be both good and bad; the system offered them for verification.

  • Spring @Controller is an add-on for Servlets. Spring installs its Servlet, which works for all url and redirects the request to a specific controller. Teach mater.chast, like no one keeps it secret and everything can be found in the same documentation for Spring. And as for servlets, even in Russian materials to ... much shorter from the time of the first appearance of this technology. - Sergey

1 answer 1

No, a servlet is an application that catches everything inside its context path. You need to make a router that will parse the url and call the appropriate code (controller). Actually, this is what spring is doing, you can easily repeat its basis by creating a similar annotation, scanning the run with your application in runtime and finding the match for the current URL given in the annotation.

  • Actually the context along with the contex path is really allocated to the application. But servlet! = App. This is its component. There may be many, maybe one. - Sergey