Last active
November 11, 2018 13:39
-
-
Save Ikhiloya/1cd55db3536406549e4958c32320c1f1 to your computer and use it in GitHub Desktop.
Controller method to test spring boot internalization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Autowired | |
| MessageSource messageSource; | |
| @RequestMapping(value = "/get-greeting", method = RequestMethod.GET) | |
| public String greeting() { | |
| /** | |
| * @LocaleContextHolder.getLocale() | |
| * Return the Locale associated with the given user context,if any, or the system default Locale otherwise. | |
| * This is effectively a replacement for Locale.getDefault(), able to optionally respect a user-level Locale setting. | |
| */ | |
| return messageSource.getMessage("good.morning", null, LocaleContextHolder.getLocale()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment