title: spring MVC HTTP Status 404
body: <p>I followed <a href="http://www.codejava.net/frameworks/spring/creating-a-spring-mvc-project-using-maven-and-eclipse-in-one-minute" rel="nofollow noreferrer">this tutorial</a> to make a simple MVC project, and I added one more controller and view. But now, whichever link out of following I use, I always get this error in chrome:</p>
  
  <pre><code>HTTP Status 404 - /spring-MVC
  
  type Status report
  
  message /spring-MVC
  
  description The requested resource is not available.
  
  Apache Tomcat/8.0.30
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
      &lt;display-name&gt;spring-MVC&lt;/display-name&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;
              org.springframework.web.context.support.AnnotationConfigWebApplicationContext
          &lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;listener&gt;
          &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
      &lt;/listener&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;SpringDispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextClass&lt;/param-name&gt;
              &lt;param-value&gt;
                  org.springframework.web.context.support.AnnotationConfigWebApplicationContext
              &lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;spring_maven.spring_MVC&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;SpringDispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
      &lt;session-config&gt;
          &lt;session-timeout&gt;30&lt;/session-timeout&gt;
      &lt;/session-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>MvcConfiguration.java:</p>
  
  <pre><code>package spring_maven.spring_MVC.config;
  
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.web.servlet.ViewResolver;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
  import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  import org.springframework.web.servlet.view.InternalResourceViewResolver;
  
  @Configuration
  @ComponentScan(basePackages="spring_maven.spring_MVC")
  @EnableWebMvc
  public class MvcConfiguration extends WebMvcConfigurerAdapter{
  
      @Bean
      public ViewResolver getViewResolver(){
          InternalResourceViewResolver resolver = new InternalResourceViewResolver();
          resolver.setPrefix("/WEB-INF/views/");
          resolver.setSuffix(".jsp");
          return resolver;
      }
  
      @Override
      public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
      }
  
  
  }
  </code></pre>
  
  <p>HomeController.java:</p>
  
  <pre><code>package spring_maven.spring_MVC.controller;
  
  import java.io.IOException;
  
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  public class HomeController {
  
  
      @RequestMapping(value="/")
      public ModelAndView ejub(HttpServletResponse response) throws IOException{
          return new ModelAndView("home.jsp");
      }
  }
  </code></pre>
  
  <p>PlacesController.java:</p>
  
  <pre><code>package spring_maven.spring_MVC.controller;
  
  
  import java.io.IOException;
  
  import javax.servlet.http.HttpServletResponse;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  public class PlacesController {
  
      @RequestMapping(value="/getAllPlaces")
      public ModelAndView getAllPlaces() throws IOException{
          return new ModelAndView("getAllPlaces.jsp");
      }
  }
  </code></pre>
  
  <p>home.jsp:</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&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=UTF-8"&gt;
          &lt;title&gt;Home&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Hello World!&lt;/h1&gt;
          &lt;p&gt;This is the homepage!&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>getAllPlaces.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;getAllPlaces&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  eeeee
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the structure of files in eclipse:</p>
  
  <p><a href="https://i.stack.imgur.com/BfpSI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BfpSI.jpg" alt="enter image description here"></a></p>
  
  <p>So as far as I see, these links should work, but they produce the mentioned errors:</p>
  
  <p><a href="http://localhost:8080/spring-MVC" rel="nofollow noreferrer">http://localhost:8080/spring-MVC</a>
  <a href="http://localhost:8080/spring-MVC/getAllPlaces" rel="nofollow noreferrer">http://localhost:8080/spring-MVC/getAllPlaces</a>
  <a href="http://localhost:8080/spring-MVC/home" rel="nofollow noreferrer">http://localhost:8080/spring-MVC/home</a></p>
  
  <p>What did I do wrong?</p>