在web开发中,安全第一位!过滤器,拦截器…
安全框架:shiro、SpringSecurity:很像,除了类不一样,名字不一样
认证、授权(vip1,vip2,vip3)
Spring Security 是一个功能强大且高度可定制的身份验证
和访问控制
框架。它是保护基于 Spring 的应用程序的事实标准。
- 功能权限
- 访问权限
- 菜单权限
- …过滤器,拦截器:大量的原生代码,冗余
记住几个类
- WebSecurityConfigurerAdaper :自定义Security策略
- AuthenticationManangerBuilder :自定义认证策略
- @EnableWebSecurity:开启WebSecurity模式,@EnableXXX开启某个功能
1、使用thymeleaf
在pom.xml中导入thymeleaf依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
在application.properties中关闭缓存
spring.thymeleaf.cache=false
2、搭建环境写controller
层
@Controller
public class RouterController {
@RequestMapping({
"/","index"})
public String index(){
return "index";
}
@RequestMapping("/tologin")
public String tologin(){
return "views/login";
}
@RequestMapping("/level1/{id}")
public String level1(@PathVariable("id") int id){
return "views/level1"+id;
}
@RequestMapping("/level2/{id}")
public String level2(@PathVariable(