diff --git a/src/main/java/shiro/shirorealm/CustomRealm.java b/src/main/java/shiro/shirorealm/CustomRealm.java index 631f3ac..cf1acc5 100644 --- a/src/main/java/shiro/shirorealm/CustomRealm.java +++ b/src/main/java/shiro/shirorealm/CustomRealm.java @@ -37,6 +37,4 @@ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authent protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { return null; } - - } diff --git a/src/main/java/web/LoginController.java b/src/main/java/web/LoginController.java index fd4a12d..be348a6 100644 --- a/src/main/java/web/LoginController.java +++ b/src/main/java/web/LoginController.java @@ -5,6 +5,7 @@ import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.crypto.hash.Md5Hash; import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -12,8 +13,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import service.ShiroUserService; +import util.MD5Util; import javax.servlet.http.HttpServletRequest; +import java.rmi.activation.UnknownObjectException; /** * Created by xuweijie on 2017/3/3. @@ -21,7 +24,7 @@ @Controller public class LoginController { - @RequestMapping(value = "/login",method = RequestMethod.GET) + @RequestMapping(value = "/login",method = RequestMethod.POST) public String login(HttpServletRequest request, Model model){ CustomException customException=null; String username=request.getParameter("username"); @@ -36,7 +39,6 @@ public String login(HttpServletRequest request, Model model){ } if( subject.isAuthenticated()){ subject.logout(); - System.out.println("认证成功"); model.addAttribute("username",username); return "/loginsuccess"; }else { diff --git a/src/main/resources/spring/spring-shiro.xml b/src/main/resources/spring/spring-shiro.xml index 5f1c7a2..1d64538 100644 --- a/src/main/resources/spring/spring-shiro.xml +++ b/src/main/resources/spring/spring-shiro.xml @@ -39,7 +39,6 @@ - \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index b8a9139..f7b9375 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -2,9 +2,8 @@ Shiro 测试项目首页 - -

这是首页

+ diff --git a/src/main/webapp/WEB-INF/jsp/login.jsp b/src/main/webapp/WEB-INF/jsp/login.jsp index 82e1720..40fe5a5 100644 --- a/src/main/webapp/WEB-INF/jsp/login.jsp +++ b/src/main/webapp/WEB-INF/jsp/login.jsp @@ -9,7 +9,7 @@

登录




-
+ 用  户  名:


密      码:

       diff --git a/src/main/webapp/WEB-INF/jsp/loginsuccess.jsp b/src/main/webapp/WEB-INF/jsp/loginsuccess.jsp index 5c173ed..b5205ec 100644 --- a/src/main/webapp/WEB-INF/jsp/loginsuccess.jsp +++ b/src/main/webapp/WEB-INF/jsp/loginsuccess.jsp @@ -11,6 +11,9 @@ 成功登录 -

用户名:${username}

+
+

用户名:${username}

+
+ diff --git a/src/main/webapp/WEB-INF/jsp/refuse.jsp b/src/main/webapp/WEB-INF/jsp/refuse.jsp index 69836af..0d6fa05 100644 --- a/src/main/webapp/WEB-INF/jsp/refuse.jsp +++ b/src/main/webapp/WEB-INF/jsp/refuse.jsp @@ -11,8 +11,9 @@ 认证失败 -

认证失败的异常信息:


-${exception} - +
+

认证失败的异常信息:


+ ${exception} +
diff --git a/src/test/java/testmd5.java b/src/test/java/testmd5.java new file mode 100644 index 0000000..89e059f --- /dev/null +++ b/src/test/java/testmd5.java @@ -0,0 +1,14 @@ +import org.junit.Test; +import util.MD5Util; + +/** + * Created by xuweijie on 2017/3/7. + */ +public class testmd5 { + + @Test + public void md5(){ + String pwd=MD5Util.md5("654321","xuweijie"); + System.out.print("pwd:"+pwd); + } +}