Spring: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler

1k Views Asked by At

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?

0

There are 0 best solutions below