Skip to content

Instantly share code, notes, and snippets.

@ricston-git
Last active December 25, 2015 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ricston-git/6934218 to your computer and use it in GitHub Desktop.
Save ricston-git/6934218 to your computer and use it in GitHub Desktop.
@Controller
public class myControllerExample{
@Autowired
MessageSource msgSource;
@RequestMapping(value="/", method= RequestMethod.CREATE)
public String create(Model uiModel, HttpServletRequest request)
{
//I get the message from the property file
//using getMessage(String code, Object[] arguments, String defaultMessage, Locale locale);
/* * defaultMessage is only used if the property file isn't found
* or you don't have a default property file for the current language.
* You can create a default property file for each language, for that you only have
* to write it without the lang extension (_es or _en, etc.) * */
msgSource.getMessage("myMessageCode", null, "Hello world!", request);
uiModel.addAttribute("viewMsg",msg); //This will add a property to the view.
return "view1";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment