title: Spring MVC Controller issue : No mapping found for HTTP request with URI
body: <p>Yes. I know this is familiar issue. I have looked into other solutions and they didn't help me. I am trying to build Spring MVC Application with Spring 4, Hibernate 5, My Sql and Angular JS 1.x</p>
  
  <p><strong>Problem</strong>: As shown in image, When I run the application, it resolved to index.jsp file as expected, then I entered '<code>http://localhost:8080/TimeLee/user/test</code>' to get web page 'adduser.html' . Boom, it throws following error '<strong>No mapping found for HTTP request with URI [/TimeLee/WEB-INF/views/adduser.html] in DispatcherServlet with name 'mvc-dispatcher</strong>'. I checked controller mappings and everything looks good. </p>
  
  <p><a href="https://i.stack.imgur.com/9Jekd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Jekd.png" alt="Folder Structure and Error message from log"></a></p>
  
  <p><a href="https://i.stack.imgur.com/9Ak1M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9Ak1M.png" alt="Browser Output"></a></p>
  
  <p>UserController:</p>
  
  <pre><code>package com.timelee.users.controllers;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  import org.springframework.web.servlet.ModelAndView;
  
  import com.timelee.users.model.User;
  import com.timelee.users.services.UserService;
  
  @RestController
  @RequestMapping("/user")
  public class UserController
  {
      @Autowired
      private UserService userService;
  
      @RequestMapping(value="/adduser",method=RequestMethod.POST)
      public void saveUser(@RequestBody User user)
      {
          userService.saveUser(user);
      }
  
  
      @RequestMapping(value="/getuser",method=RequestMethod.GET)
      public @ResponseBody User getUser(@RequestParam("userId") String userId)
      {
          return userService.getUser(userId);
      }   
  
      @RequestMapping(value="/test",method=RequestMethod.GET)
      public  ModelAndView test()
      {
          ModelAndView modelAndView=new ModelAndView("adduser");
          return modelAndView;
      }
  
      @RequestMapping(value="/test2",method=RequestMethod.GET)
      public  String test2()
      {
          return "adduser";
      }
  
  }
  </code></pre>
  
  <p>web.xml</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;Spring Web MVC Application&lt;/display-name&gt;
  
      &lt;servlet&gt;
          &lt;servlet-name&gt;mvc-dispatcher&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;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring-mvc-config.xml&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;mvc-dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>spring-mvc-config.xml</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:tx="http://www.springframework.org/schema/tx" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.springframework.org/schema/context
      http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"&gt;
  
      &lt;bean id="viewResolver"
          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;.html&lt;/value&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
      &lt;context:property-placeholder location="classpath:database.properties" /&gt;
        &lt;context:component-scan  base-package="com.timelee.*" /&gt;
  
  
      &lt;tx:annotation-driven transaction-manager="transactionManager"/&gt;
  
  
       &lt;!--  &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;  --&gt;
  
       &lt;bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource"&gt;
         &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt;
          &lt;property name="url" value="${jdbc.url}"/&gt;
          &lt;property name="username" value="${jdbc.username}" /&gt;
          &lt;property name="password" value="${jdbc.password}"/&gt;
  
      &lt;/bean&gt;
  
  
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" &gt;
          &lt;property name="dataSource" ref="dataSource"/&gt;
          &lt;property name="packagesToScan"&gt;
              &lt;list&gt;
                  &lt;value&gt;com.timelee.timesheet.model&lt;/value&gt;
                  &lt;value&gt;com.timelee.users.model&lt;/value&gt;
                  &lt;value&gt;com.timelee.*&lt;/value&gt;
              &lt;/list&gt;
          &lt;/property&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql:false}&lt;/prop&gt;
                  &lt;prop key="hibernate.format_sql"&gt;${hibernate.format_sql:false}&lt;/prop&gt;
                  &lt;prop key="hibernate.hbm2ddl.auto"&gt;update&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;       
      &lt;/bean&gt;
  
      &lt;bean id="transactionManager"  class="org.springframework.orm.hibernate5.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="persistenceExceptionTranslationPostProcessor"
          class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/&gt;
  
  &lt;/beans&gt;
  </code></pre>