From 317172aa4bf88c42a10de858f4d9509b4909e104 Mon Sep 17 00:00:00 2001 From: Chenx221 Date: Fri, 16 Jun 2023 13:06:33 +0800 Subject: [PATCH] fix login fail issue Signed-off-by: Chenx221 --- .../chenx221/controller/ViewController.class | Bin 1414 -> 1414 bytes .../CustomAuthenticationSuccessHandler.class | Bin 0 -> 1282 bytes .../WEB-INF/classes/spring-security.xml | 1 + .../WEB-INF/views/teachermanage.jsp | 39 +++++++----------- .../chenx221/controller/ViewController.java | 1 + .../CustomAuthenticationSuccessHandler.java | 20 +++++++++ .../src/main/resources/spring-security.xml | 1 + project2/web/WEB-INF/views/teachermanage.jsp | 39 +++++++----------- 8 files changed, 53 insertions(+), 48 deletions(-) create mode 100644 project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.class create mode 100644 project2/src/main/java/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.java diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/ViewController.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/controller/ViewController.class index f7da260782bd3e5dc00af0c9dd35274f4f5f217a..b8a281fe45c3beaa97b44a14ca5575299341d592 100644 GIT binary patch delta 13 UcmZqUZsXn{!OAEzS&}su02o38D*ylh delta 13 UcmZqUZsXn{!OAE-S&}su02n<3DgXcg diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.class b/project2/out/artifacts/project2_war_exploded/WEB-INF/classes/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.class new file mode 100644 index 0000000000000000000000000000000000000000..bb67392c1e77bd9244786ec6b0cb18f3b82992d8 GIT binary patch literal 1282 zcmbVMTTc@~6#k|Z7GVLoRKN==inQf2ktbu-gftpViY8S0zFm&(=mRA%`Icc^AVN5!lzJCF71!QR}_& zLORmsqm0Q$%Y?~she9tN!$+`+V0qvV$yU$-we4pZY$BPaEG6EydRHW<+ zfuUllF^*AOb1>#&9In912k+23<|^heAS>I}cH|D5de^Z>pAw3#z*viHok6**z;dxv zyEHG0sf=P$z$Ig}+2u5^MdP@RX$LbdW-%wQbTxp$l%Y@`(zdlmH4{q$g<@7!242*X zb#_OsN~w{Oc*Dg!76j&XbRiW2pS!sOZ(6zhVi`kw6nAtKQ>AugvwUqx_8*0h>folp z6aPdf(&s)NZ*4u6?QWN3HHobb`&0gGWWK5on1`vFis(%eHp#s6ngM%eYTEaLhG$f| z?m6?etzv)#n>nZ7*ssgn*z z?4T$xo2pDIEnmMq-*Hg>OMX4MpT{s#T_?t;S1RRqb#Qk!(@Fx1dkN2HNDUP$ZpC&K zX`2lzccOgpjVu|`_M}6yszVkR4|oOlvB diff --git a/project2/out/artifacts/project2_war_exploded/WEB-INF/views/teachermanage.jsp b/project2/out/artifacts/project2_war_exploded/WEB-INF/views/teachermanage.jsp index 682206f..b9de02b 100644 --- a/project2/out/artifacts/project2_war_exploded/WEB-INF/views/teachermanage.jsp +++ b/project2/out/artifacts/project2_war_exploded/WEB-INF/views/teachermanage.jsp @@ -146,7 +146,7 @@ 授课课程ID 授课课程名 授课班级 - <%-- 操作--%> + 操作 @@ -159,26 +159,16 @@ ${teacher.course.courseID} ${teacher.course.courseName} ${teacher.classes} - <%-- --%> - <%--
--%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%--
--%> - <%-- --%> + +
+ + +
+ @@ -282,7 +272,8 @@
- +
@@ -361,7 +352,8 @@
- +
@@ -466,7 +458,6 @@ - diff --git a/project2/src/main/java/cyou/chenx221/controller/ViewController.java b/project2/src/main/java/cyou/chenx221/controller/ViewController.java index c93196c..b1d25e6 100644 --- a/project2/src/main/java/cyou/chenx221/controller/ViewController.java +++ b/project2/src/main/java/cyou/chenx221/controller/ViewController.java @@ -24,6 +24,7 @@ public class ViewController { if (username != null) { model.addAttribute("username", username); } +// model.addAttribute("errorMessage","null"); return "dashboard"; // 返回 dashboard 视图名 } diff --git a/project2/src/main/java/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.java b/project2/src/main/java/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.java new file mode 100644 index 0000000..c7f06db --- /dev/null +++ b/project2/src/main/java/cyou/chenx221/handler/CustomAuthenticationSuccessHandler.java @@ -0,0 +1,20 @@ +package cyou.chenx221.handler; + +import org.springframework.security.core.Authentication; +import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler; +import org.springframework.stereotype.Component; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +@Component +public class CustomAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler { + + @Override + public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { + request.getSession().removeAttribute("errorMessage"); + super.onAuthenticationSuccess(request, response, authentication); + } +} \ No newline at end of file diff --git a/project2/src/main/resources/spring-security.xml b/project2/src/main/resources/spring-security.xml index d5f54d4..28a1779 100644 --- a/project2/src/main/resources/spring-security.xml +++ b/project2/src/main/resources/spring-security.xml @@ -30,6 +30,7 @@ diff --git a/project2/web/WEB-INF/views/teachermanage.jsp b/project2/web/WEB-INF/views/teachermanage.jsp index 682206f..b9de02b 100644 --- a/project2/web/WEB-INF/views/teachermanage.jsp +++ b/project2/web/WEB-INF/views/teachermanage.jsp @@ -146,7 +146,7 @@ 授课课程ID 授课课程名 授课班级 - <%-- 操作--%> + 操作 @@ -159,26 +159,16 @@ ${teacher.course.courseID} ${teacher.course.courseName} ${teacher.classes} - <%-- --%> - <%--
--%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%-- --%> - <%--
--%> - <%-- --%> + +
+ + +
+ @@ -282,7 +272,8 @@
- +
@@ -361,7 +352,8 @@
- +
@@ -466,7 +458,6 @@ -