title: Getting 404 error when executing spring MVC
body: <p>I am getting 404 error every time executing Spring application. I have created the dynamic web project using eclipse. I am new to spring and use eclipse first time. Please help to solve this issue. </p>
  
  <p>My web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;display-name&gt;SpringBasic&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;spring&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;/web-app&gt;
  </code></pre>
  
  <p>spring-servlet.xml</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"  
      xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      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.xsd
  http://www.springframework.org/schema/mvc
  http://www.springframework.org/schema/mvc/spring-mvc.xsd
  http://www.springframework.org/schema/data/jpa
  http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"&gt;
  
  &lt;context:component-scan base-package="com.bt.controller" /&gt;
  &lt;mvc:annotation-driven /&gt;
  
  
  
        &lt;bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
        &lt;property name = "prefix" value = "/WEB-INF/jsp/" /&gt;
        &lt;property name = "suffix" value = ".jsp" /&gt;
     &lt;/bean&gt;
  
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>MyController</p>
  
  <pre><code>  package com.bt.controller;
  
  import org.springframework.stereotype.Controller;  
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.servlet.ModelAndView;  
  
  @Controller
  public class MyController {
  
  
       @RequestMapping("/")
       @ResponseBody
        public ModelAndView loadhellopage() {
           System.out.println("controller");
          String msg="Finally";
          ModelAndView mav=new ModelAndView("hellopage");
          mav.addObject("msg", "Finally");
           return mav;
        }
  
  }
  </code></pre>
  
  <p>hellopage.jsp:</p>
  
  <pre><code>  &lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      ${message} 
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>this is my folder structure:</p>
  
  <p><a href="https://i.stack.imgur.com/vXvQv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vXvQv.jpg" alt="Folder Structure"></a></p>
  
  <p>Also included all the jar files in lib folder under WEB-INF.</p>
  
  <p>When running the project on apache tomcat it is giving 404 error</p>