java - How should I send resourcebundle messages across controllers in spring mvc? -


most of spring tutorials , examples show how message resource file , how show in view (jsp), not how should handle messages in controller , between views.

here example of how im doing have view/controller handles forgotten passwords. when password sent redirect login screen message "your password sent ..."

@requestmapping(value="/forgottenpassword") public string forgottenpassword(@requestparam string email) {      ....something      if(email != null){          return "redirect:/login?forgottenpassword=ok";      } }  @requestmapping(value="/login") public string login(httpservletrequest request) {     if(request.getparameter("forgottenpassword") != null && request.getparameter("forgottenpassword").equals("ok")) {         data.put("ok_forgottenpassword", "forgottenpassword.ok");     }      return "login"; } 

finaly display message in view, in case freemarker template

<#if (ok_forgottenpassword?exists)>      <div class="alert alert-success"><@spring.message "${ok_forgottenpassword}" /></div> </#if> 

is best way of doing in spring framework? it's simple 1 type of message, if need 5?

just create simple bean , push data. in bean can have messages want loaded resourcebundle. (by way: really need resource bundle? few fancy tricks unnecessary unless need i18n. simple properties file suffice in every other case.)


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -