Spring:DispatcherServlet配置需要包含支持该处理程序的HandlerAdapter
我们正在尝试将 spring 从 4.x 升级到 5.3.x
这是dispatcher-servlet.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- The facade for the ConfigOps EJB -->
<bean id="configOps" class="com.sample.Config" scope="prototype" />
<!-- Main controller beans-->
<bean id="actionController" class="com.ui.controllers.ActionController" >
<property name="configOps" ref="configOps" />
</bean>
<bean id="nodeController" class="com.ui.controllers.NodeController" >
<property name="configOps" ref="configOps" />
</bean>
<bean id="wizardController" class="com.ui.controllers.WizardController" >
<property name="configOps" ref="configOps" />
<property name="nodeController" ref="nodeController" />
</bean>
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">errorView</prop>
</props>
</property>
</bean>
<!-- Simple URL based handler mapping -->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/**/actions.do=actionController
/**/nodes.do=nodeController
/**/wizard.do=wizardController
</value>
</property>
</bean>
<!-- View resolver for action controllers -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
</bean>
</beans>
注意:这里的 Wizardcontroller 用 @controller 进行注释,它具有像 @Requestmapping 和这样的注释 NodeController,ActionController 扩展了 AbstractController,它有一些方法。
我尝试根据一些答案在调度程序 xml 文件中添加 mvc:annotation-driven ,但仍然是同样的问题..
我们如何更改代码以与 spring 5.3.x 一起使用?
we are trying to upgrade spring from 4.x to 5.3.x
this is the dispatcher-servlet.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- The facade for the ConfigOps EJB -->
<bean id="configOps" class="com.sample.Config" scope="prototype" />
<!-- Main controller beans-->
<bean id="actionController" class="com.ui.controllers.ActionController" >
<property name="configOps" ref="configOps" />
</bean>
<bean id="nodeController" class="com.ui.controllers.NodeController" >
<property name="configOps" ref="configOps" />
</bean>
<bean id="wizardController" class="com.ui.controllers.WizardController" >
<property name="configOps" ref="configOps" />
<property name="nodeController" ref="nodeController" />
</bean>
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.Exception">errorView</prop>
</props>
</property>
</bean>
<!-- Simple URL based handler mapping -->
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/**/actions.do=actionController
/**/nodes.do=nodeController
/**/wizard.do=wizardController
</value>
</property>
</bean>
<!-- View resolver for action controllers -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
</bean>
</beans>
Note: here wizardcontroller is annotated with @controller which has annotation like @Requestmapping and
nodecontroller,actioncontroller extends abstractcontroller which has some methods.
i tried by adding mvc:annotation-driven in dispatcher xml file as per some of answers, but still same issue..
how we can the change the code to work with spring 5.3.x?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论