title: How to set up web.xml and dispatcher-servlet.xml for mapping?
body: <p>I want to change from @WebServlet Mapping to SpringMVC Mapping. To get comfortable with things I set up an easy simple LoginApplication with use of @WebServlet.</p>
  
  <p>Now I wanted to do the switch to springMVC by adding web.xml and dispatcher-servlet.xml</p>
  
  <p>I have added all necessary dependencies to my build path, including commons-logging, jstl, servlet-api, spring-aop, spring-beans, spring-context, spring-core, spring-expression, spring-web and spring-webmvc. I added @Controller @RequestMapping("XXXXX") annotations to my controllers and @GetMapping to the methods performing redirects and stuff.</p>
  
  <p>Part of my web.xml:</p>
  
  <pre><code>&lt;servlet&gt;
          &lt;servlet-name&gt;sobster&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;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/sobster-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;sobster&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>Part of my sobster-servlet.xml:</p>
  
  <pre><code>    &lt;context:component-scan base-package="com.sobster" /&gt;
      &lt;mvc:annotation-driven /&gt;
  </code></pre>
  
  <p>Where com.sobster is my package containing the controllers</p>
  
  <p>Part of a controller:</p>
  
  <pre><code>    @RequestMapping("/")
      @Controller
      public class StartPageController extends HttpServlet {
        private static final long serialVersionUID = 1L;
  
        @GetMapping
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
          response.sendRedirect("login.jsp");
        }
  
      }
  </code></pre>
  
  <p>I expected any request now to get handled by web.xml which looks up sobster-servlet.xml to get the controllers. sobster-servlet.xml now checks controllers in com.sobster and performs according action (redirecting to login.jsp after receiving call from "/" for example).</p>
  
  <p>But all I get is HTTP Status 404 – Not Found</p>
  
  <p>I appreciate any suggestions :-)</p>