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

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";
}
}
主站蜘蛛池模板: 海宁市| 华宁县| 贡觉县| 梧州市| 六枝特区| 灵丘县| 建平县| 孟津县| 炎陵县| 苏尼特左旗| 永城市| 临清市| 韶山市| 桦甸市| 西宁市| 隆回县| 南溪县| 东乌| 松江区| 南乐县| 平昌县| 平利县| 铜山县| 定陶县| 沂水县| 安塞县| 彩票| 南召县| 株洲市| 兴和县| 临清市| 竹溪县| 涟水县| 军事| 朝阳市| 白城市| 呼玛县| 土默特左旗| 炉霍县| 泽州县| 莎车县|