title: Page not found error in spring mvc 4 although it exists
body: <p>I am developing a small application using spring mvc 4 which gets the input from user and inserts it into the database.
  Here is the dispatcher-servlet.xml </p>
  
  <pre><code>    &lt;?xml version='1.0' encoding='UTF-8' ?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:context="http://www.springframework.org/schema/context"
          xmlns:p="http://www.springframework.org/schema/p"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      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/mvc 
          http://www.springframework.org/schema/mvc/spring-mvc.xsd
          http://www.springframework.org/schema/context 
          http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
          &lt;context:component-scan base-package="controllers.FormController" /&gt;
  
      &lt;bean id="viewResolver"
            class="org.springframework.web.servlet.view.InternalResourceViewResolver"
            p:prefix="/WEB-INF/jsp/"
            p:suffix=".jsp" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>And here is my controller</p>
  
  <pre><code>    @Controller
  @RequestMapping("/form")
  public class FormController {
  
      @Autowired
      private FormService formService;
  
      public FormService getFormService() {
          return formService;
      }
  
      public void setFormService(FormService formService) {
          this.formService = formService;
      }
      @RequestMapping(value = "/userForm", method = RequestMethod.GET)
  public String showUser(Model model){
      User user = new User();
      model.addAttribute("userForm", user);
      return "index";
  }
      @RequestMapping(value = "/adduser", method = RequestMethod.POST)
      public String addUser(@ModelAttribute("userForm") User user, BindingResult result, Model model){
          formService.insert(user.getUsername(), user.getPassword());
          return "success";
      }
  }
  </code></pre>
  
  <p>When i type the following url in browser "<a href="http://localhost:8080/FormSpring/form/userForm.htm" rel="nofollow noreferrer">http://localhost:8080/FormSpring/form/userForm.htm</a>", it shows me the page not found error, although the success page is located in the WEB-INF/jsp directory</p>
  
  <p>Here is the web.xml file</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/applicationContext.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;2&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;*.htm&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;welcome-file-list&gt;
          &lt;welcome-file&gt;redirect.jsp&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>Also, the structure of the project is shown in the image bellow</p>
  
  <p><a href="https://i.stack.imgur.com/aWRbb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aWRbb.png" alt="enter image description here"></a></p>