HandlerMappings

HandlerMappings

HandlerMapping is a component in Spring Web MVC Framework, it will take the incoming request URI and it will identify the mapped Controller class through Spring configuration file and return that Controller class details to DispatcherServlet.

Spring Web MVC has provided a set of predefined HandlerMappings in the package like “org.springframework.web.servlet.handler”.

Spring Web MVC has provided the following predefined HandlerMapping classes.

  1. BeanNameUrlHandlerMapping
  2. SimpleUrlHandlerMapping
  3. ControllerClassNameHandlerMapping
  4. DefaultAnnotationHandlerMapping
1. BeanNameUrlHandlerMapping

It is the default HandlerMapping in Spring web MVC applications if we use XML configurations, it is not required to configure in Spring configuration file.
BeanNameUrlHandlerMapping is able to identify the Controller classes by mapping the incoming request URI with the Bean identity[“id” attribute value] or Bean logical name[“name” attribute value] which we defined in Spring configuration file.

E.g

ds-servlet.xml

<beans>
   -----
   <bean name="handlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
   <bean name="/welcome" class="com.ashok.spring.controller.WelcomeController"/>
   ------
</beans>

If we submit request with the URI “welcome” then BeannameUrlHandler-Mapping is able to map “welcome” with “name” attribute value in tag , if it is matched then BeanNameUrlHandlerMapping will confirm the respective Controller class is “com.ashok.spring.controller.Welcome Controller” and send its details to DispatcherServlet.

E.g

http://localhost:1010/app/welcome

Example

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
   <jsp:forward page="helloform"/>
</body>
</html>

helloform.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-
//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<h2 style="color: red;" align="center">Welcome to Waytoeasylearn</h2>
	<h3 style="color: blue;" align="center">User Hello Form</h3>
	<form method="POST" action="wish">
		<center>
			<table>
				<tr>
					<td>User Name</td>
					<td><input type="text" name="uname" /></td>
				</tr>
				<tr>
					<td><input type="submit" value="SayHello" /></td>
				</tr>
			</table>
		</center>
	</form>
</body>
</html>

wish.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
   pageEncoding="ISO-8859-1"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
  <head>
     <meta charset="ISO-8859-1">
     <title>Spring MVC</title>
  </head>
  <body>
     <h1>Waytoeasylearn</h1>
     <h2>Hello..!!, ${message}.</h2>
  </body>
</html>

HelloController.java

package com.ashok.spring.mvc.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class HelloController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("helloform");
   }
}

WishController.java

package com.ashok.spring.mvc.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class WishController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      String uname = request.getParameter("uname");
      return new ModelAndView("wish", "uname", uname);
   }
}

ds-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">
   <bean name="/hello." class="com.ashok.spring.mvc.controller.HelloController"/>
   <bean name="/wish." class="com.ashok.spring.mvc.controller.WishController"/>
   <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/"/>
      <property name="suffix" value=".jsp"/>
   </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
   id="WebApp_ID" version="4.0">
   <display-name>MVC</display-name>
   <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
      <servlet-name>ds</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>ds</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>
2. SimpleUrlHandlerMapping

org.springframework.web.servlet.handler.SimpleUrlHandlerMapping is able to map the in coming request with a particular Controller class and it will provide the respective Controller class details to DispatcherServlet with the following actions.

  • SimpleUrlHandlerMapping will take incoming request URI value.
  • It will search for the Request URI name in its Properties which are configured in Spring Configuration file.
  • If any property key is matched with incoming request URI value then SimpleUrlHandlerMapping will take the corresponding property value, that is, logical name of the Controller class.
  • SimpleUrlHandlerMapping will identify the controller class on the basis of logical name which we get from the matched property.
<beans>
   <bean name="wishController" class="com.ashok.spring.mvc.controller.WishController"/>
   <bean name="welcomeController" class="com.ashok.spring.mvc.controller.WelcomeController"/>
   <bean name="handlerMapping" class="org.....handler.SimpleUrlHandlerMapping"/>
      <property name="mappings">
         <props>
            <prop key="/wish">wishController</prop>
            <prop key="/welcome">welcomeController</prop>
         </props>
      </property>
   </bean>
   -----
</beans>

From the above example, if we submit request with the URI “wish” then SimpleUrlHandlerMapping will map this URI with properties names configured in Spring configuration file and it will identify “wishController” as value and it will identify the respective controller class like “com.ashok.spring.mvc.controllers.WishController” from Spring configuration file.

E.g

http://localhost:1010/app/wish ----> wishController ---> WishController
http://localhost:1010/app/welcome ---> welcomeController --> WelcomeController

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
   <jsp:forward page="helloform"/>
</body>
</html>

helloform.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-
//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<h2 style="color: red;" align="center">Welcome to Waytoeasylearn</h2>
	<h3 style="color: blue;" align="center">User Hello Form</h3>
	<form method="POST" action="wish">
		<center>
			<table>
				<tr>
					<td>User Name</td>
					<td><input type="text" name="uname" /></td>
				</tr>
				<tr>
					<td><input type="submit" value="SayHello" /></td>
				</tr>
			</table>
		</center>
	</form>
</body>
</html>

wish.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
   pageEncoding="ISO-8859-1"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
  <head>
     <meta charset="ISO-8859-1">
     <title>Spring MVC</title>
  </head>
  <body>
     <h1>Waytoeasylearn</h1>
     <h2>Hello..!!, ${message}.</h2>
  </body>
</html>

HelloController.java

package com.ashok.spring.mvc.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class HelloController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("helloform");
   }
}

WishController.java

package com.ashok.spring.mvc.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class WishController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      String uname = request.getParameter("uname");
      return new ModelAndView("wish", "uname", uname);
   }
}

ds-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">
   <bean name="/hello." class="com.ashok.spring.mvc.controller.HelloController"/>
   <bean name="/wish." class="com.ashok.spring.mvc.controller.WishController"/>
   <bean name="handlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      <property name="mappings">
         <props>
            <prop key="/hello">helloFormController</prop>
            <prop key="/wish">wishController</prop>
         </props>
      </property>
   </bean>
   <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
   id="WebApp_ID" version="4.0">
   <display-name>MVC</display-name>
   <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
      <servlet-name>ds</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>ds</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>
3. ControllerClassHandlerMapping

org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping is able to map the incoming request URI with the Controller class by following the below convention.

  • It will take request URI value and removes extension if any extension.
  • It will make the first letter as Upper Case letter in the Request URI value.
  • It will append Controller to the modified Request URI value.
  • It will search for the respective controller class with the above convention and sends that Controller class details to DispatcherServlet.

If we submit a request with the URI value “wish” then ControllerClassNameHandlerMapping will search for the Controller class with the name “WishController”, in this context, “name” attribute must not be provided in the Controller class configuration

<beans ...>
   <bean name="handlerMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
   <bean class="com.ashok.spring.mvc.controller.HelloController" />
   <bean class="com.ashok.spring.mvc.controller.WelcomeController" />
</beans>

In the above example, if we submit request with the Request URI “wish” then WishController class will be mapped.

If we submit request with the URI “welcome” then WelcomeController class will be mapped.

E.g

helloform ---->HelloFormController --> Valid
helloForm ---->HelloFormController --> Invalid, where 'F' is not matched.

If we want to map the request URI with the Contrlller class names in case insensitive manner then we have to use “caseSensitive” property with the value “true”.

<beans ...>
   <bean name="handlerMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
   <property name="caseSensitive" value="true"/>
   <bean class="com.ashok.spring.mvc.controller.HelloController" />
   <bean class="com.ashok.spring.mvc.controller.WelcomeController" />
</beans>

E.g

helloform ----> HelloFormController --> Invalid, 'f' is not matched.
helloForm ----> HelloFormController --> valid.

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
   <jsp:forward page="helloform"/>
</body>
</html>

helloform.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-
//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<h2 style="color: red;" align="center">Welcome to Waytoeasylearn</h2>
	<h3 style="color: blue;" align="center">User Hello Form</h3>
	<form method="POST" action="wish">
		<center>
			<table>
				<tr>
					<td>User Name</td>
					<td><input type="text" name="uname" /></td>
				</tr>
				<tr>
					<td><input type="submit" value="SayHello" /></td>
				</tr>
			</table>
		</center>
	</form>
</body>
</html>

wish.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
   pageEncoding="ISO-8859-1"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
  <head>
     <meta charset="ISO-8859-1">
     <title>Spring MVC</title>
  </head>
  <body>
     <h1>Waytoeasylearn</h1>
     <h2>Hello..!!, ${message}.</h2>
  </body>
</html>

HelloController.java

package com.ashok.spring.mvc.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class HelloController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("helloform");
   }
}

WishController.java

package com.ashok.spring.mvc.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class WishController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      String uname = request.getParameter("uname");
      return new ModelAndView("wish", "uname", uname);
   }
}

ds-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">
   <bean name="/hello." class="com.ashok.spring.mvc.controller.HelloController"/>
   <bean name="/wish." class="com.ashok.spring.mvc.controller.WishController"/>
   <bean name="handlerMapping" class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
      <property name="caseSensitive" value="true"/>
   </bean>
   <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="mappings">
         <props>
            <prop key="/hello">helloFormController</prop>
            <prop key="/wish">wishController</prop>
         </props>
      </property>
   </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
   id="WebApp_ID" version="4.0">
   <display-name>MVC</display-name>
   <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
      <servlet-name>ds</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>ds</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>
4. DefaultAnnotationHandlerMapping

org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping is a default HandlerMapping class in Spring WEB MVC applications if we use Annotations , it is not required to configure in Spring configuration File.

It will map incoming request URI with the name provided along with the @RequestMapping annotation which we provided above of the controller class or Controller class method.

E.g

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
   <jsp:forward page="helloform"/>
</body>
</html>

helloform.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-
//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
	<h2 style="color: red;" align="center">Welcome to Waytoeasylearn</h2>
	<h3 style="color: blue;" align="center">User Hello Form</h3>
	<form method="POST" action="wish">
		<center>
			<table>
				<tr>
					<td>User Name</td>
					<td><input type="text" name="uname" /></td>
				</tr>
				<tr>
					<td><input type="submit" value="SayHello" /></td>
				</tr>
			</table>
		</center>
	</form>
</body>
</html>

wish.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
   pageEncoding="ISO-8859-1"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
  <head>
     <meta charset="ISO-8859-1">
     <title>Spring MVC</title>
  </head>
  <body>
     <h1>Waytoeasylearn</h1>
     <h2>Hello..!!, ${message}.</h2>
  </body>
</html>

HelloController.java

package com.ashok.spring.mvc.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

public class HelloController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      return new ModelAndView("helloform");
   }
}

WishController.java

package com.ashok.spring.mvc.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
public class WishController implements Controller {
   @Override
   public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
      String uname = request.getParameter("uname");
      return new ModelAndView("wish", "uname", uname);
   }
}

ds-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context.xsd">
   <bean name="/hello." class="com.ashok.spring.mvc.controller.HelloController"/>
   <bean name="/wish." class="com.ashok.spring.mvc.controller.WishController"/>
   <bean name="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>      <property name="caseSensitive" value="true"/>
   </bean>
   <bean name="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="mappings">
         <props>
            <prop key="/hello">helloFormController</prop>
            <prop key="/wish">wishController</prop>
         </props>
      </property>
   </bean>
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://xmlns.jcp.org/xml/ns/javaee"
   xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
   id="WebApp_ID" version="4.0">
   <display-name>MVC</display-name>
   <welcome-file-list>
      <welcome-file>index.html</welcome-file>
      <welcome-file>index.htm</welcome-file>
      <welcome-file>index.jsp</welcome-file>
      <welcome-file>default.html</welcome-file>
      <welcome-file>default.htm</welcome-file>
      <welcome-file>default.jsp</welcome-file>
   </welcome-file-list>
   <servlet>
      <servlet-name>ds</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <load-on-startup>1</load-on-startup>
   </servlet>
   <servlet-mapping>
      <servlet-name>ds</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>
</web-app>

Note

In Single Spring WEB MVC applications we are able to configure more than one HandlerMapping classes in spring configuration file, if we want to provide a particular order to execute them then we have to declare “order” property with a particular value at each and every HandlerMapping class, where if the order value is low then the HandlerMapping class will get high
priority and if the order value is high then the respective Handlermapping class will get less priority.

HandlerMappings
Scroll to top