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

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";
}
}
主站蜘蛛池模板: 九江县| 太康县| 吐鲁番市| 诸城市| 建湖县| 广宗县| 陆良县| 江门市| 吉林省| 河间市| 改则县| 高青县| 西城区| 许昌市| 梧州市| 鲜城| 桂东县| 大厂| 漠河县| 望谟县| 怀安县| 雷州市| 叙永县| 尚义县| 泰来县| 修武县| 夏津县| 华蓥市| 偏关县| 峨眉山市| 图片| 时尚| 托里县| 南和县| 佛坪县| 台北市| 苏尼特右旗| 东平县| 罗定市| 扶沟县| 伽师县|