ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 第一步 配置视图 ~~~ @Configuration public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http.formLogin()//设置自定义的登录页面 .loginPage("/login.html")//登录页面设置 .loginProcessingUrl("/user/login")//登录访问的路径Security 的 .defaultSuccessUrl("/edu").permitAll() //登录成功,跳转路径 .and().authorizeRequests()//设置被保护的路径 .antMatchers("/").permitAll()//设置不需要验证的路径 .anyRequest().authenticated()//设置所有路径都可以访问 .and().csrf().disable();//关闭csrf防护 } } ~~~ # 第二步编写试图 ~~~ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <form action="/user/login" method="post"> 用户名: <input type="text" name="username"> <br> 密码: <input type="text" name="password"> <br> <input type="submit" value="登录"> </form> </body> </html> ~~~ ![](https://img.kancloud.cn/73/69/7369b883191813d8ab89a93f3b1e5745_401x108.png)