Skip to content

Instantly share code, notes, and snippets.

@pikanji
Last active December 11, 2015 08:19
Show Gist options
  • Save pikanji/4572772 to your computer and use it in GitHub Desktop.
Save pikanji/4572772 to your computer and use it in GitHub Desktop.
Sample Spring MVC controller method that passes user name of the user logged in.
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model, Principal principal) {
//...
if (null != principal) {
model.addAttribute("userName", principal.getName());
}
//...
return "home";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment