title: How should I send resourcebundle messages across controllers in spring mvc?
body: <p>Most of the spring tutorials and examples show you how to get the message from the resource file and how to show it in your view (jsp), but not how you should handle those messages in your controller and between views. </p>
  
  <p>Here is an example of how im doing it now where I have a view/controller that handles forgotten passwords. When the password is sent I redirect back to the login screen with a message that "your password is sent ..."</p>
  
  <pre><code>@RequestMapping(value="/forgottenpassword")
  public String forgottenpassword(@RequestParam String email) {
       ....something something
       if(email != null){
           return "redirect:/login?forgottenpassword=ok";
       }
  }
  
  @RequestMapping(value="/login")
  public String login(HttpServletRequest request) {
      if(request.getParameter("forgottenpassword") != null &amp;&amp; request.getParameter("forgottenpassword").equals("ok")) {
          data.put("ok_forgottenpassword", "forgottenpassword.ok");
      }
  
      return "login";
  }
  </code></pre>
  
  <p>Finaly I display the message in my view, in this case a freemarker template</p>
  
  <pre><code>&lt;#if (ok_forgottenpassword?exists)&gt;
       &lt;div class="alert alert-success"&gt;&lt;@spring.message "${ok_forgottenpassword}" /&gt;&lt;/div&gt;
  &lt;/#if&gt;
  </code></pre>
  
  <p>Is this the best way of doing it in a Spring framework? It's simple with just 1 type of message, but what if I need 5?</p>