title: Spring MVC: ModelAndView objects are not getting carried to the view
body: <p>I am currently trying show variables from the controller into the view, the view is not showing them.</p>
  
  <p>Thanks for any help!</p>
  
  <p>UserController.java</p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.ui.ModelMap;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  
  @Controller
  @RequestMapping(value="/user")
  public class UserController {
  
    @RequestMapping(method = RequestMethod.GET)
    public String login(ModelMap model) {
      model.put("message", "added Var from controller");
      return "user/login";
    }
  }
  </code></pre>
  
  <p>Also tried</p>
  
  <pre><code>ModelAndView modelAndView = new ModelAndView();
  modelAndView.setViewName("user/login");
  modelAndView.addObject("message", "Hello World");
  return modelAndView;
  </code></pre>
  
  <p>JSP</p>
  
  <pre><code>&lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;h2&gt;Login&lt;/h2&gt;
  
    &lt;p&gt;This is my message: ${message}&lt;/p&gt;
    &lt;c:out value="${message}" /&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;h2&gt;Login&lt;/h2&gt;
  
    &lt;p&gt;This is my message: ${message}&lt;/p&gt;
    ${message}
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My Spring servlet-context.xml</p>
  
  <pre><code>    &lt;context:component-scan base-package="com.web.controllers" /&gt;
  
    &lt;bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/&gt;
    &lt;bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/&gt;
    &lt;bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/&gt;
    &lt;bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/&gt;
      &lt;property name="prefix" value="/view/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
    &lt;/bean&gt;
  </code></pre>
  
  <p>Is there anything I am doing wrong ?</p>