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

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";
}
}
主站蜘蛛池模板: 南投市| 醴陵市| 东明县| 辽源市| 维西| 斗六市| 漳浦县| 凌海市| 永胜县| 温州市| 外汇| 博乐市| 巫溪县| 北宁市| 马山县| 灵石县| 玉山县| 洛阳市| 合肥市| 博兴县| 灵台县| 嘉兴市| 绥滨县| 汤原县| 冀州市| 云林县| 霍林郭勒市| 太仆寺旗| 湟源县| 北碚区| 南涧| 徐汇区| 始兴县| 巴青县| 迁西县| 缙云县| 申扎县| 铜山县| 隆化县| 靖安县| 申扎县|