Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training

ControllerClassNameHandlerMapping class for handling convention mapping

In this section, you will learn about handling mapping in convention style using ControllerClassNameHandlerMapping class.

Ads

Tutorials   
Spring 3.2 MVC insert and retrieve blob from the database The hidden tag The errors tag net.roseindia.dao net.roseindia.service net.roseindia.model net.roseindia.controller Spring 3.2 MVC Hibernate Example Spring 3.2 MVC, Upload File in a specific folder Spring 3.2 MVC Form Handling The textarea tag The options tag The option tag The select tag The radiobuttons tag The radiobutton tag The checkboxes tag mvc:default-servlet-handler Static Resources Configuration View Controllers Configuration View resolvers Spring 3.2 MVC Hello World Example Content Negotiation Configuration Interceptors Configuration using Java or XML Customizing the MVC Java config or XML Namespace MVC Java Config or the MVC XML Namespace Servlet container initialization through code Support for ETag The checkbox tag Autogenerated logical view name through RequestToViewNameTranslator Modification in conventional ModelAndView ControllerClassNameHandlerMapping class for handling convention mapping The password tag The input tag The form tag Form Tag library configuration Customizing the Default Error Page @ExceptionHandler & @ResponseStatus annotation Multipart support for file upload in Spring MVC Themes and Theme resolvers in Spring MVC Locales in Spring MVC ContentNegotiatingViewResolver Redirecting and forwarding to views Chaining of Multiple view resolvers View Resolving through ViewResolver interface Requests Intercepting through a HandlerInterceptor Defining handler methods using @RequestMapping annotation Spring 3.2 Asynchronous Request Processing @RequestMapping annotation for mapping requests @Controller annotation for defining new controller
Ads

ControllerClassNameHandlerMapping class for handling convention mapping

In this section, you will learn about handling mapping in convention style using ControllerClassNameHandlerMapping class.

Spring 3.2 supports conventional style mapping through ControllerClassNameHandlerMapping class. You need to configure ControllerClassNameHandlerMapping class in Spring MVC configuration file. This class determines the mapping between request URLs and the Controller, which handle these requests.

The ControllerClassNameHandlerMapping discovers all the Controllers defined in application context and removes the 'Controller' from their name. The resultant name will be the request URL.

For example :

  • WelcomeController maps to the /welcome* request URL

  • HomeController maps to the /home* request URL

To understand it completely, consider a scenario :

Suppose we have a simple controller :

public class FormHandlerController implements Controller {

	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) {
		// implementation
	}
}

The Spring MVC configuration file contains the related configuration for the above controller :

<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>

<bean id="formHandler" class="a.b.c.FormHandlerController ">
	<!-- dependencies -->
</bean>

ControllerClassNameHandlerMapping class finds all the Controller defined in the configuration file and chops the Controller from their name to specify its handler mappings.

In the above case, the ControllerClassNameHandlerMapping class  chops the Controller from its name and define its handler mapping. So the FormHandlerController  maps to the /formhandler* request URL.

You can represent it graphically as :

FormHandlerController -------------maps to------------> /formhandler*

Advertisements

Share on Google+Share on Google+

ControllerClassNameHandlerMapping class for handling convention mapping

Posted on: January 28, 2013 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

Ads
 

Discuss: ControllerClassNameHandlerMapping class for handling convention mapping  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads