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

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";
}
}
主站蜘蛛池模板: 盐津县| 廉江市| 抚顺县| 南京市| 托克逊县| 南通市| 盐津县| 谢通门县| 承德县| 徐州市| 镇江市| 十堰市| 广安市| 盐亭县| 革吉县| 饶平县| 旬阳县| 连江县| 祁东县| 合江县| 台山市| 靖江市| 成安县| 和硕县| 佛山市| 右玉县| 碌曲县| 兴安县| 永城市| 牙克石市| 泰顺县| 肥乡县| 桃江县| 柏乡县| 巴南区| 闸北区| 阿克陶县| 天门市| 竹北市| 峨眉山市| 盖州市|