為了做到零配置用到了ControllerClassNameHandlerMapping,訪問預(yù)先設(shè)定好的url,總會出現(xiàn)No?mapping?for?[/springT/registration.hr]?in?DispatcherServlet?with?name?'Dispatcher'
1
?
2
??????<!--?SpringMVC相關(guān)Bean配置?-->?
3
????<bean?class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>?
4
????<!--?以下為Controller?-->??
5
????<bean?id="registrationController"?class="com.RegistrationController"/>
6
?????<bean?id="userController"?class="com.UserController"?scope="request"/>

2

3

4

5

6

看似Controller都已經(jīng)注入到Spring中:







訪問debug錯誤信息如下:
1
2010-07-17?15:49:50?Looking?up?handler?for?[/registration.hr]
2
2010-07-17?15:49:50?No?mapping?for?[/springT/registration.hr]?in?DispatcherServlet?with?name?'Dispatcher'

2

通過多方努力,同事的幫助下,發(fā)現(xiàn)是缺包spring-web.jar、spring-webmvc.jar,也真搞笑,缺兩個包居然沒有錯誤,特此記錄
1
2010-07-17?16:55:00?Rejected?bean?name?'org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0':?no?URL?paths?identified
2
2010-07-17?16:55:00?Creating?shared?instance?of?singleton?bean?'registrationController'
3
2010-07-17?16:55:00?Creating?instance?of?bean?'registrationController'
4
2010-07-17?16:55:00?Eagerly?caching?bean?'registrationController'?to?allow?for?resolving?potential?circular?references
5
2010-07-17?16:55:00?Finished?creating?instance?of?bean?'registrationController'
6
2010-07-17?16:55:00?Mapped?URL?path?[/registration*]?onto?handler?[com.RegistrationController@4dc957]
7
2010-07-17?16:55:00?Mapped?URL?path?[/user*]?onto?handler?[userController]

2

3

4

5

6

7

中間最大的差異就是
正確:
???Mapped?URL?path?[/registration*]?onto?handler?[com.RegistrationController@4dc957]
錯誤:
???Mapped?URL?path?[/registration]?onto?handler?[com.RegistrationController@1a2af25