首先,构建一个简单的Web工程,以用于后续添加安全控制,也可以用之前Chapter3-1-2做为基础工程。若对如何使用Spring Boot构建Web应用,可以先阅读《Spring Boot开发Web应用》一文。
Web层实现请求映射@Controller
public class HelloController {
@RequestMapping("/")
public String index() {
return "index";
}
@RequestMapping("/hello")
public String hello() {
return "hello";
}
}/:映射到index.html
/hello:映射到hello.html
src/main/resources/templates/index.htmlSpring Security入门 欢迎使用Spring Security!点击 这里 打个招呼吧
src/main/resources/templates/hello.html
Hello World! Hello world!
可以看到在index.html中提供到/hello的链接,显然在这里没有任何安全控制,所以点击链接后就可以直接跳转到hello.html页面。



