Skip to content

Commit f7c4888

Browse files
committed
modify thymeleaf permission
1 parent 8994781 commit f7c4888

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

springboot-security/src/main/java/com/us/example/config/WebMvcConfig.java

-17
This file was deleted.

springboot-security/src/main/java/com/us/example/config/WebSecurityConfig.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception {
3636
@Override
3737
protected void configure(HttpSecurity http) throws Exception {
3838
http.authorizeRequests()
39-
.antMatchers("/index.js.map").permitAll()
39+
.antMatchers("/css/**").permitAll()
4040
.anyRequest().authenticated() //任何请求,登录后可以访问
4141
.and()
4242
.formLogin()
43+
.loginPage("/login")
44+
.defaultSuccessUrl("/")
4345
.failureUrl("/login?error")
4446
.permitAll() //登录页面用户任意访问
4547
.and()
4648
.logout().permitAll(); //注销行为任意访问
4749
http.addFilterBefore(myFilterSecurityInterceptor, FilterSecurityInterceptor.class);
48-
49-
5050
}
51+
5152
}
5253

springboot-security/src/main/java/com/us/example/controller/HomeController.java

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public String index(Model model){
1919
return "home";
2020
}
2121

22+
@RequestMapping("/login")
23+
public String login(){
24+
return "login";
25+
}
2226

2327
@RequestMapping("/admin")
2428
@ResponseBody

springboot-security/src/main/resources/templates/login.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
2-
<html xmlns:th="http://www.thymeleaf.org">
2+
<html xmlns:th="http://www.thymeleaf.org"
3+
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
34
<head>
45
<meta content="text/html;charset=UTF-8"/>
56
<title>登录页面</title>

0 commit comments

Comments
 (0)