Spring framework - url mapping not resolving

Viewed 43

Everything used to work before upgrading. I have upgraded to Spring framework 5.3 and updated configuration file . I am getting FineNotFound error when accessing contextRoot(index.html) or any other requests.

Web.exml

<servlet>
<servlet-name>abcd</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>abcd</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>

configuration.xml

  <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:aop="http://www.springframework.org/schema/aop"
   xmlns:mvc="http://www.springframework.org/schema/mvc"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:util="http://www.springframework.org/schema/util"
   xmlns:oxm="http://www.springframework.org/schema/oxm"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.1.xsd
   http://www.springframework.org/schema/mvc
   http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
   http://www.springframework.org/schema/util
   http://www.springframework.org/schema/util/spring-util-3.1.xsd
   http://www.springframework.org/schema/aop 
   http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
   http://www.springframework.org/schema/oxm
   http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
   
 <context:component-scan base-package="xxx.aaa.abcd.controller,xxx.aaa.abcd.bean,xxx.aaa.abcd.bean.command,xxx.aaa.abcd.validator" />    
<context:annotation-config />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />    
<mvc:default-servlet-handler/>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="urlMap">
        <map>
        <entry key="/report.xls"><ref bean="viewStatReportController" /></entry>                                   
        </map>
    </property>
    <property name="interceptors">
        <list>
            <ref bean="securityInterceptor"/>
        </list>
    </property>
    <property name="mappings">
<props>
  <prop key="index.html">homeController</prop>
</props>
 </property>
</bean>

When trying to access localhost:9080/abcd - it is redirecting to localhost:9080/abcd/index.html which is correct but getting FileNotFoundErore.javax.servlet.ServletException: java.io.FileNotFoundException: SRVE0190E: File not found: /index.html at
Whether I keep <prop key="index.html">homeController</prop> or remove it. Result is same.

1 Answers

Removed - mvc:default-servlet-handler/ and it worked.

Related