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

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";
}
}
主站蜘蛛池模板: 金湖县| 太白县| 淳化县| 建宁县| 塔城市| 庐江县| 彩票| 潜江市| 阿城市| 弋阳县| 瑞丽市| 蓝山县| 石门县| 金乡县| 文化| 桓台县| 昌乐县| 无锡市| 常山县| 桦川县| 崇左市| 嘉祥县| 康保县| 阳东县| 烟台市| 新兴县| 怀来县| 闸北区| 枝江市| 南部县| 抚宁县| 离岛区| 林周县| 内江市| 巴东县| 江门市| 水城县| 正蓝旗| 叙永县| 开原市| 沙田区|