第一步:准备静态资源
- 在resources/static/imgs下放置一张名称为mm01.jpg的图片
- 在resources/static/css下创建文件demo.css
.cc{
font-size: 38px;
color: red;
}
- 在resources/static/js下创建文件demo.js
function fun() {
alert(3+2);
}
第二步:修改index.html
首页
首页
fun()
第三步:修改SpringSecurity配置文件
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
//授权
.antMatchers("/openIndex").permitAll()//toLogin放行:不需要拦截,可以随便访问
.antMatchers("/**/*.css","/**/*.js","/imgs/**").permitAll() //放行静态资源
.anyRequest().authenticated()//其它请求都必须认证后才能访问
.and()
//关闭防火墙:为了保证完整流程可用关闭CSRF安全协议
.csrf().disable();
}