Why, when, and when should we use multiple servlets instead of a single servlet in spring mvc?

I start learning Spring MVC yesterday, then I believe that in Spring MVC (or maybe in a different environment) we can have many servlets in one web application.
The Serblet has a url template that will match if there is any HTTP request. In the other hand, we can simply use @RequestMapping to do the mapping for the HTTP request. So the question is why, when, and when should we use multiple servlets?
What is the best practice for this?

Thank.

+3
source share
2 answers

Spring MVC web.xml :

<servlet>
    <servlet-name>ActivityReplicator</servlet-name>
    <servlet-class>
        org.springframework.web.servlet.DispatcherServlet
    </servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>ActivityReplicator</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

.

, web.xml. Spring , DispatcherServlet. , .

, . , , -. Restfull Spring, , .

+2

, - API RESTful , - , Spring MVC. API Spring - .

0

All Articles