Code example for Principal

Methods: getName

0
@Controller 
public class WelcomeController { 
 
	@RequestMapping(value="/user/welcome.do", method = RequestMethod.GET) 
	public String printWelcome(ModelMap model, Principal principal) {
		String name = principal.getName();
		model.addAttribute("userName", name);
		 
		return "hello"; 
	} 
	 
	@RequestMapping(value="/public/login.do",method=RequestMethod.GET) 
	public String login(ModelMap model){
		return "login"; 
	} 
	@RequestMapping(value="/public/loginfailed.do" , method = RequestMethod.GET) 
	public String loginFailed(ModelMap model){
		model.addAttribute("error", "true");
		return "login"; 
	} 
	@RequestMapping(value="/public/logout.do", method=RequestMethod.GET)