弹簧引导中使用Spring Security如何实现安全控制?很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
<强>准备工作强>
首先,构建一个简单的网工程,以用于后续添加安全控制,也可以用之前Chapter3-1-2做为基础工程。若对如何使用弹簧引导构建网络应用,可以先阅读《春天引导开发网络应用》一文。
Web层实现请求映射
@ controller 公开课HelloController { @RequestMapping (“/? 公共字符串索引(){ 返回“index"; } @RequestMapping (“/hello") 公共字符串hello () { 返回“hello"; } }
- <李>/:映射到索引。李李html > <>/你好:映射到hello.html李>
<强>实现映射的页面强>
src/main/资源/模板/索引。html
& lt; !DOCTYPE html> http://www.w3.org/1999/xhtml" & lt; html xmlns=?xmlns: th=癶ttp://www.thymeleaf.org"xmlns:秒=癶ttp://www.thymeleaf.org/thymeleaf-extras-springsecurity3"比; & lt; head> & lt; title> Spring Security入门& lt;/title> & lt;/head> & lt; body> & lt; h2>欢迎使用Spring Security ! & lt;/h2> & lt; p>点击& lt; th: href=https://www.yisu.com/zixun/癅{/你好}”rel="外部nofollow”>这里>打个招呼吧 身体>