随笔 - 31  文章 - 2  trackbacks - 0
做为spring的新手,很愿意尝试这样的优秀框架,但最近做项目时,总是碰到恼人的问题
为了做到零配置用到了ControllerClassNameHandlerMapping,访问预先设定好的url,总会出现No mapping for [/springT/registration.hr] in DispatcherServlet with name 'Dispatcher'

1 
2      <!-- SpringMVC相关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"/>

看似Controller都已经注入到Spring中:

2010-07-17 15:48:23 Registering Controller 'registrationController' as handler for URL path [/registration]
2010-07-17 15:48:23 Creating shared instance of singleton bean 'registrationController'
2010-07-17 15:48:23 Creating instance of bean 'registrationController'
2010-07-17 15:48:23 Eagerly caching bean 'registrationController' to allow for resolving potential circular references
2010-07-17 15:48:23 Finished creating instance of bean 'registrationController'
2010-07-17 15:48:23 Mapped URL path [/registration] onto handler [com.RegistrationController@1a2af25]
2010-07-17 15:48:23 Registering Controller 'userController' as handler for URL path [/user]

访问debug错误信息如下:

12010-07-17 15:49:50 Looking up handler for [/registration.hr]
22010-07-17 15:49:50 No mapping for [/springT/registration.hr] in DispatcherServlet with name 'Dispatcher'

通过多方努力,同事的帮助下,发现是缺包spring-web.jar、spring-webmvc.jar,也真搞笑,缺两个包居然没有错误,特此记录

12010-07-17 16:55:00 Rejected bean name 'org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping#0': no URL paths identified
22010-07-17 16:55:00 Creating shared instance of singleton bean 'registrationController'
32010-07-17 16:55:00 Creating instance of bean 'registrationController'
42010-07-17 16:55:00 Eagerly caching bean 'registrationController' to allow for resolving potential circular references
52010-07-17 16:55:00 Finished creating instance of bean 'registrationController'
62010-07-17 16:55:00 Mapped URL path [/registration*] onto handler [com.RegistrationController@4dc957]
72010-07-17 16:55:00 Mapped URL path [/user*] onto handler [userController]


中间最大的差异就是
正确:
   Mapped URL path [/registration*] onto handler [com.RegistrationController@4dc957]
错误:
   Mapped URL path [/registration] onto handler [com.RegistrationController@1a2af25
posted on 2010-07-17 18:29 缘来如此 阅读(4283) 评论(0)  编辑  收藏 所属分类: ssh

只有注册用户登录后才能发表评论。


网站导航: