【SSM項目實戰講解】汽車租賃管理系統項目功能演示與課程說明
配置模板頁面
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <% String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/"; %> <html> <head> <title>管理員登錄頁面</title> <link rel="stylesheet" href="<%=basePath%>layui/css/layui.css"/> <script type="text/javascript" src="<%=basePath%>js/jquery.js"></script> <script type="text/javascript" src="<%=basePath%>layui/layui.js"></script> </head> <body> <div> </div> </body>
``
******在 shiro課程講解中有完整的講解過 Realm的定義****
```javascript
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException { log.info("========登錄授權認證========"); // 1 、取得用戶名 String username = (String) authenticationToken.getPrincipal(); try { Admin vo = this.adminServiceBack.login(username); if (vo == null) { throw new UnknownAccountException("用戶不存在!"); } else { // 2 、取得登錄密碼 String password = (new String((char[]) authenticationToken.getCredentials())); if (vo.getPassword().equals(password)) { AuthenticationInfo auth = new SimpleAuthenticationInfo(username, password, "adminRealm"); return auth; } else { throw new IncorrectCredentialsException("密碼錯誤!");
**課程問題答疑:**