I am using Spring 3.0 for my new application…I am not very familiar with annotation but learning them they are cool. Today I faced “Cannot Map Handler [XXX] to URL Path” error, while running my page.
Later debug I found that I duplicated the Controller definition stuff inside XXX-Servlet.xml as below.
<context:component-scan base-package="org.me.spring.web" />
<bean class="org.me.spring.web.SampleController" >
The first line will auto-discover and register a SampleController for you. By explicitly declaring another one, you get a duplicate, and the url-mapping will clash.
You need to either remove the <context:component-scan>, or remove the explicit bean definitions for the controller and the DAO. If you do the latter, then you’ll need to use autowiring to inject their dependencies.