官术网_书友最值得收藏!

Step 8—Controller setup

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:

@Controller
public class HomeController {

@GetMapping("/")
public String home(Model model, Principal principal) {
if(principal != null)
model.addAttribute("msg", "Welcome " + principal.getName());
return "home";
}
}
主站蜘蛛池模板: 玛纳斯县| 竹山县| 昌吉市| 二手房| 彩票| 横山县| 西充县| 德兴市| 林甸县| 龙胜| 高安市| 保德县| 西和县| 浏阳市| 北辰区| 汕尾市| 时尚| 大庆市| 阳新县| 林甸县| 沁阳市| 山丹县| 浦东新区| 曲水县| 明水县| 嘉鱼县| 远安县| 湘阴县| 永福县| 潮州市| 咸丰县| 浙江省| 常熟市| 沧州市| 修武县| 集安市| 邵武市| 扬州市| 沿河| 株洲市| 海淀区|