I've found a difference in the behavior of Spring MVC with respect to @RequestMapping annotations -- in Spring 3.0.2.RELEASE, the following example works, but against Spring 2.5.6.SEC01, the exact same controller code and configuration (except for the change in Spring dependencies) is broken, resulting in "No mapping found for HTTP request with URI" error messages.
Here's my sole context configuration file (yes, using the 2.5 XSDs in both the Spring 3 and Spring 2.5 tests):
Code:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<context:component-scan base-package="org.example.springmvctest" />
<bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
And my controller class:
Code:
@Controller
@RequestMapping("/abc")
public class SampleController {
@RequestMapping("/def")
public String myMethod(Model model) {
model.addAttribute("thing", "myMethod");
return "xyz";
}
@RequestMapping("/ghi")
public String myOtherMethod(Model model) {
model.addAttribute("thing", "myOtherMethod");
return "xyz";
}
}
And my jsp view template "WEB-INF/views/xyz.jsp":When I run my webapp against Spring 3.0.2.RELEASE, everything works fine. When I run the exact same code & context config file against Spring 2.5.6.SEC01, I get the HandlerMapping error:
Code:
DEBUG: org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'Spring MVC Dispatcher Servlet' determining Last-Modified value for [/blargy/app/abc/ghi]
DEBUG: org.springframework.web.servlet.DispatcherServlet - No handler found in getLastModified
DEBUG: org.springframework.web.servlet.DispatcherServlet - DispatcherServlet with name 'Spring MVC Dispatcher Servlet' processing request for [/blargy/app/abc/ghi]
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/blargy/app/abc/ghi] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
DEBUG: org.springframework.web.servlet.DispatcherServlet - Successfully completed request
What gives? What additional context configuration do I need to add to Spring 2.5 in order to make it work, given that it works as is against Spring 3?
-matthew