【发布时间】:2010-07-08 15:35:03
【问题描述】:
我有一个用 2.5 编写的现有 Spring MVC 应用程序。
我想使用新的注解控制器。我有点看到它非常灵活,可以满足我的其他需求。
我的问题是,我似乎不能同时使用它们。
<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="com.test.web" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
<!-- Controller Mappings Here -->
<bean id="homeController" class="com.test.web.HomeController">
<property name="cacheSeconds" value="120" />
</bean>
//other plain old spring mvc controller
当我运行我的应用程序并点击主页时,出现以下错误:
javax.servlet.ServletException:处理程序没有适配器 [com.test.web.HomeController@cca07b]:您的处理程序是否实现了像 Controller 这样的受支持接口?
我不确定,但我认为有些矛盾。这是一个相当大的 Spring MVC 应用程序,我不想更改那些已经使用旧 Spring Base Controller 工作的模块。
我的目标是仅在我的新增强功能中使用注释控制器。
【问题讨论】:
标签: java spring spring-mvc