title: No mapping found for HTTP request with URI [/Spring4MVCHelloWorld/hello/] in DispatcherServlet with name 'dispatcher'
body: <p>I tried SpringMVC example mentioned here- <a href="http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/" rel="nofollow">http://javahash.com/spring-4-mvc-hello-world-tutorial-full-example/</a>. I have customised the web.xml and the dispatcher servlet and not getting the results.</p>
  
  <p>I am getting the error page as configured under error page tag when I hit the URL-/Spring4MVCHelloWorld/hello/?name=JavaHash</p>
  
  <p>However, if I hit the URL - /Spring4MVCHelloWorld/
  I am getting the page as specified  in the welcome file list, that is the index.jsp page.</p>
  
  <p>The expected behaviour is that helloworld.jsp should be loaded when the user hits the first URL. It was working but I changed something in my dispatcher servlet and the web.xml file.</p>
  
  <p>Here is my web.xml file -</p>
  
  <pre><code>&lt;web-app id="WebApp_ID" 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;Web Application&lt;/display-name&gt;
  
   &lt;welcome-file-list&gt;
     &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;context-param&gt;
       &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
       &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&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;dispatcher&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;dispatcher&lt;/servlet-name&gt;
       &lt;url-pattern&gt;/&lt;/url-pattern&gt;
   &lt;/servlet-mapping&gt;
  
   &lt;error-page&gt;
      &lt;error-code&gt;404&lt;/error-code&gt;
      &lt;location&gt;/WEB-INF/errors/404.jsp&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my dispatcher-servlet file - </p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
   &lt;context:component-scan base-package="com.javahash.spring.controller" /&gt;
   &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
       &lt;property name="prefix"&gt;
          &lt;value&gt;/WEB-INF/views/&lt;/value&gt;
       &lt;/property&gt;
       &lt;property name="suffix"&gt;
          &lt;value&gt;.jsp&lt;/value&gt;
       &lt;/property&gt;
   &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the controller file - </p>
  
  <pre><code>@Controller
   public class HelloWorldController { 
  
  @RequestMapping("/hello")
  public String hello(@RequestParam(value="name", required=false, defaultValue="World") String name, Model model) {
      model.addAttribute("name", name);
      return "helloworld";
  }
  }
  </code></pre>
  
  <p>The helloWorld.jsp has the following contents -</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;Spring4 MVC -HelloWorld&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
     &lt;h1&gt;Hello : ${name}&lt;/h1&gt; 
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>