SpringMVC Mapping

BeanNameUrlHandlerMapping

spring 默认使用的HandlerMapping实现,通过bean配置实现url转发

ControllerClassNameHandlerMapping

启用这个HandlerMapping后,spring采用约定方式实现url转发

<br /> 

 

 

WelcomeController -> /welcome*
HelloGuestController -> /helloguest*
/helloGuest匹配/helloguest错误

Case sensitive
配置启用caseSensitive属性

<br /> 

 

 

WelcomeController -> /welcome*
HelloGuestController -> /helloGuest*

pathPrefix

<br /> 

 

 

WelcomeController -> /customer/welcome*
HelloGuestController -> /customer/helloGuest*

SimpleUrlHandlerMapping

通过url pattern配置转发
两种配置方式

welcomeControllerwelcomeControllerhelloGuestController

 

 
<br />/welcome.htm=welcomeController
/*/welcome.htm=welcomeController
/helloGuest.htm=helloGuestController
 

 

handler mapping priority

ControllerClassNameHandlerMapping配置所有符合约定的mapping
SimpleUrlHandlerMapping配置所有由特殊需求的mapping
然后指定order

<br />/index.htm=welcomeController
/welcome.htm=welcomeController
/main.htm=welcomeController
/home.htm=welcomeController
 

 

 
Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s