July 2018
Intermediate to advanced
268 pages
7h 36m
English
Let's create a base controller (HomeController) for the secured JSP page (home.jsp). Please note that the return of the mapping method should be a string, and it should map to the actual name of the JSP file. In our case, it is home.jsp, a secured resource that the caller navigates when they log in:
@Controllerpublic class HomeController { @GetMapping("/") public String home(Model model, Principal principal) { if(principal != null) model.addAttribute("msg", "Welcome " + principal.getName()); return "home"; }}
Read now
Unlock full access