Spring MVC SimpleUrlHandlerMapping example

In Spring MVC application, the SimpleUrlHandlerMapping is the most flexible handler mapping class, which allow developer to specify the mapping of URL pattern and handlers explicitly.
The SimpleUrlHandlerMapping can be declared in two ways.

1. Method 1 – prop key

The property keys are the URL patterns while the property values are the handler IDs or names.

 
     
         
             
                welcomeController 
               welcomeController 
               helloGuestController 
            
         
     
         
     

2. Method 1 – value

The left side are the URL patterns while the right side are the handler IDs or names, separate by a equal symbol “=”.

 
     
         
            
                          /welcome.htm=welcomeController           
                          /*/welcome.htm=welcomeController        
                          /helloGuest.htm=helloGuestController 
            
         
     

        
     

3. Demo

Both are defined the same handler mappings.

/welcome.htm –> welcomeController.
/{anything}/welcome.htm –> welcomeController.
/helloGuest.htm –> helloGuestController.

你可能感兴趣的:(Spring MVC SimpleUrlHandlerMapping example)