From f983d7f92f3f0f3afe87a89e23444a092c574884 Mon Sep 17 00:00:00 2001 From: wanglufei <2686221966@qq.com> Date: Mon, 11 Apr 2022 16:02:52 +0800 Subject: [PATCH] =?UTF-8?q?thymeleaf=E6=95=B4=E5=90=88SpringSecurity5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rg_attoparser_attoparser_2_0_5_RELEASE.xml | 13 +++++++++ ...t_spring_boot_starter_thymeleaf_2_5_12.xml | 13 +++++++++ ...ymeleaf_extras_java8time_3_0_4_RELEASE.xml | 13 +++++++++ ...f_extras_springsecurity5_3_0_4_RELEASE.xml | 13 +++++++++ ...org_thymeleaf_thymeleaf_3_0_15_RELEASE.xml | 13 +++++++++ ...eleaf_thymeleaf_spring5_3_0_15_RELEASE.xml | 13 +++++++++ ..._org_unbescape_unbescape_1_1_6_RELEASE.xml | 13 +++++++++ pom.xml | 10 +++++++ springsecurity_demo.iml | 7 +++++ .../com/uin/controller/LoginController.java | 13 +++++++++ .../service/impl/UserDetailsServiceImpl.java | 3 +- src/main/resources/templates/demo.html | 29 +++++++++++++++++++ src/main/resources/templates/error.html | 4 ++- src/main/resources/templates/login.html | 6 +++- src/main/resources/templates/main.html | 4 ++- 15 files changed, 163 insertions(+), 4 deletions(-) create mode 100644 .idea/libraries/Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_5_12.xml create mode 100644 .idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_springsecurity5_3_0_4_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_thymeleaf_thymeleaf_3_0_15_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_thymeleaf_thymeleaf_spring5_3_0_15_RELEASE.xml create mode 100644 .idea/libraries/Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml create mode 100644 src/main/resources/templates/demo.html diff --git a/.idea/libraries/Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml b/.idea/libraries/Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml new file mode 100644 index 0000000..f4f0734 --- /dev/null +++ b/.idea/libraries/Maven__org_attoparser_attoparser_2_0_5_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_5_12.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_5_12.xml new file mode 100644 index 0000000..0804239 --- /dev/null +++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_thymeleaf_2_5_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml b/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml new file mode 100644 index 0000000..ecd447b --- /dev/null +++ b/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_java8time_3_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_springsecurity5_3_0_4_RELEASE.xml b/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_springsecurity5_3_0_4_RELEASE.xml new file mode 100644 index 0000000..1093d63 --- /dev/null +++ b/.idea/libraries/Maven__org_thymeleaf_extras_thymeleaf_extras_springsecurity5_3_0_4_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_thymeleaf_thymeleaf_3_0_15_RELEASE.xml b/.idea/libraries/Maven__org_thymeleaf_thymeleaf_3_0_15_RELEASE.xml new file mode 100644 index 0000000..97b230f --- /dev/null +++ b/.idea/libraries/Maven__org_thymeleaf_thymeleaf_3_0_15_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_thymeleaf_thymeleaf_spring5_3_0_15_RELEASE.xml b/.idea/libraries/Maven__org_thymeleaf_thymeleaf_spring5_3_0_15_RELEASE.xml new file mode 100644 index 0000000..c1a3033 --- /dev/null +++ b/.idea/libraries/Maven__org_thymeleaf_thymeleaf_spring5_3_0_15_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml b/.idea/libraries/Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml new file mode 100644 index 0000000..70dba61 --- /dev/null +++ b/.idea/libraries/Maven__org_unbescape_unbescape_1_1_6_RELEASE.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 518f24e..b68a96b 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,16 @@ 2.6.2 test + + + org.thymeleaf.extras + thymeleaf-extras-springsecurity5 + + + + org.springframework.boot + spring-boot-starter-thymeleaf + diff --git a/springsecurity_demo.iml b/springsecurity_demo.iml index 1d3ea9d..f442e27 100644 --- a/springsecurity_demo.iml +++ b/springsecurity_demo.iml @@ -76,5 +76,12 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/uin/controller/LoginController.java b/src/main/java/com/uin/controller/LoginController.java index edde773..9167671 100644 --- a/src/main/java/com/uin/controller/LoginController.java +++ b/src/main/java/com/uin/controller/LoginController.java @@ -6,6 +6,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; /** * @author wanglufei @@ -77,4 +78,16 @@ public String toMain3() { public String toError() { return "redirect:error.html"; } + + /** + * 跳转页面 + * + * @return java.lang.String + * @author wanglufei + * @date 2022/4/11 3:43 PM + */ + @RequestMapping("demo") + public String demo() { + return "demo"; + } } diff --git a/src/main/java/com/uin/service/impl/UserDetailsServiceImpl.java b/src/main/java/com/uin/service/impl/UserDetailsServiceImpl.java index dcd711f..30199dc 100644 --- a/src/main/java/com/uin/service/impl/UserDetailsServiceImpl.java +++ b/src/main/java/com/uin/service/impl/UserDetailsServiceImpl.java @@ -36,6 +36,7 @@ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundEx //2.把查询的密码(注册是已经加过密)进行解析,或者直接把密码放入构造方法 String password = passwordEncoder.encode("123"); return new User(username, password, AuthorityUtils.commaSeparatedStringToAuthorityList( - "admin,normal,ROLE_uin")); + "admin,normal,ROLE_uin,main.html" + + "/insert,/delete")); } } diff --git a/src/main/resources/templates/demo.html b/src/main/resources/templates/demo.html new file mode 100644 index 0000000..9107a65 --- /dev/null +++ b/src/main/resources/templates/demo.html @@ -0,0 +1,29 @@ + + + + + Title + + +登陆账号: +登陆账号: +凭证: +权限和角色: +客户端地址: +sessionId: + +通过权限判断 + + + + + +通过角色判断 + + + + + + diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html index 4ca5e2a..055c963 100644 --- a/src/main/resources/templates/error.html +++ b/src/main/resources/templates/error.html @@ -1,5 +1,7 @@ - + Title diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html index aeedfd1..c872565 100644 --- a/src/main/resources/templates/login.html +++ b/src/main/resources/templates/login.html @@ -1,5 +1,7 @@ - + login @@ -8,6 +10,8 @@
用户名: + 用户名: + 密码: 记住我: diff --git a/src/main/resources/templates/main.html b/src/main/resources/templates/main.html index a18d735..f7caf68 100644 --- a/src/main/resources/templates/main.html +++ b/src/main/resources/templates/main.html @@ -1,5 +1,7 @@ - + main