Reputation: 53806
As the title says what is the difference between dispatcher-servlet.xml and spring-servlet.xml They seem very similar in terms of structure. When should one be used over the other ?
Upvotes: 2
Views: 6741
Reputation: 36767
Here's an explanation from spring forums
Basically it's just the name. Dispather is autoloading context called [servletname]-servlet.xml so in this case there's a servlet called 'spring' and another called 'dispatcher'.
You name your servlets in web.xml
.
For example if you had:
<servlet>
<servlet-name>babubiba</servlet-name>
<servlet-class> org.springframework.web.servlet.DispatcherServlet </servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
in your web.xml
then DispatcherServlet would try to load babubiba-servlet.xml
by default.
If you can change context name by adding contextConfigLocation
init-param to your servlet config.
Upvotes: 3