Arefe
Arefe

Reputation: 1059

How to resolve Spring framework project error org.springframework.web.servlet.DispatcherServlet noHandlerFound?

I started a Spring MVC project for developing a backend and the project is here:

https://github.com/Chaklader/backend

It's just the initialization and I'm getting the following error,

Feb 12, 2016 2:23:42 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound
WARNING: No mapping found for HTTP request with URI [/myTest/] in DispatcherServlet with name 'offers'

Inside the WEB-INF folder, the web.xml file is as following,

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
  <display-name>MyBackend</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

  <servlet>
    <description></description>
    <display-name>offers</display-name>
    <servlet-name>offers</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>offers</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

and, offers-servlet.xml file (also, inside the WEB-INF folder) is as following,

    <?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:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="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-3.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.backend.test.controllers"></context:component-scan>
    <mvc:annotation-driven></mvc:annotation-driven>
<bean id="jspViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/JSP/"></property>
    <property name="suffix" value=".jsp"></property>
    </bean>
</beans>

What does it mean by noHandlerFound and how to resolve the problem ? There is a similar post in the forum, but, that doesn't help.

Upvotes: 0

Views: 617

Answers (1)

isah
isah

Reputation: 5341

It means you do not have a controller which handles the request with URI /myTest/. In your controller, you should have something like:

@RequestMapping("/myTest")
public String myTest(){
   return "viewName";
}

Upvotes: 1

Related Questions