请选择 进入手机版 | 继续访问电脑版
在线投稿 文字标题 文字标题 文字标题 文字标题 文字标题
切换皮肤
SpringBoot学习笔记四之后台登录页面的实现
继续之前完成的内容,首先创建一个常量类
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fe862fd85p00q7r4si000bc000ah005wm.jpg

常量类的内容
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fb29dc864p00q7r4si0034c001bq00ghm.jpg
服务器端渲染
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F5b9f0e78p00q7r4si007mc0011i00n7m.jpg
前后端分离
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fa4ea1d2ap00q7r4si003uc0011900ebm.jpg
完成后台管理登录页面
进入前端静态资源
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F7c33cd02p00q7r4si000oc000b200h8m.jpg
创建后台管理员登录页面admin-login.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F85e9c5adp00q7r4si000pc000b200flm.jpg
完成内容
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fb6189b89p00q7r4si003kc001dc00lvm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F5e7647efp00q7r4si002pc001dr00k1m.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fe2782edcp00q7r4si0043c001aj00o3m.jpg
然后完成页面跳转
配置mvc:view-controller
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F10011e61p00q7r4si000lc000bf00bem.jpg
完成配置
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F2f900169p00q7r4si002uc0014p00hpm.jpg
启动服务访问一下
localhost:8080/learn-admin-webui/admin/to/login/page.html
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F7c07722cp00q7r4si001ac0011v00dam.jpg
修饰system-error.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F2caac164p00q7r4si0045c001dr00ndm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Ff358d705p00q7r4si003ac001br00opm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F112d9b1ep00q7r4si003pc001eq00nym.jpg
Md5加密工具方法
添加到类
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F3b3dfdc1p00q7r4si000ec000d6006sm.jpg
编写代码
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fd0306848p00q7r4si002lc0013k00iym.jpg
接着
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F63a8b929p00q7r4si0037c0013600nvm.jpg
测试下
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F2d277cfdp00q7r4si001dc000ux00a2m.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fdfaa4d2dp00q7r4si001nc000sy00hnm.jpg
自定义异常
创建异常类
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fcb1410c5p00q7r4si000kc000cs00aam.jpg
登录失败后抛出的异常
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F3fe13327p00q7r4si002uc0016t00nom.jpg
用户没有登录就访问受保护资源时抛出的异常
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F4bf8b261p00q7r4si0036c0018g00o5m.jpg
在异常处理器中增加登录失败的异常
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F96034c01p00q7r4si002mc000z100o3m.jpg
页面显示错误的地方
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F33f895c6p00q7r4si0028c000zn00ehm.jpg
完成AdminHandler
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F204d0711p00q7r4si000kc000b100bxm.jpg
完成登录方法
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F3fdde155p00q7r4si0036c0013k00kwm.jpg
完成adminService.getAdminByLoginAcct
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F9df31cfcp00q7r4si0033c0011w00jrm.jpg
选择方法ctrl+1
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fe560dc04p00q7r4si002rc0013c00gmm.jpg
会自动在接口中写好,补好注释
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F2cda6fafp00q7r4si001xc0012r00j6m.jpg
在按ctrl+t,弹出菜单
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F2d0031efp00q7r4si001cc0010e00fdm.jpg
进入实现类后,按ctrl+!加入未实现的方法
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F4b26c50dp00q7r4si000ic000ha006um.jpg
按ctrl+o(字母),定位到我们使用的方法
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F142a9bfdp00q7r4si000ic000rh007km.jpg
完成方法体
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F5a0917aep00q7r4si002nc0013u00ljm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F56ad5438p00q7r4si002nc0014c00ndm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F57b25192p00q7r4si002qc0011900m5m.jpg
重定向到主页面
redirect:/admin/to/main/page.html
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F013d312dp00q7r4si0036c0013g00kfm.jpg
创建admin-main.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F9d94aed0p00q7r4si0013c000dj00jom.jpg
编写内容
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fc7efeac1p00q7r4si0036c0016u00iim.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fdddb45f8p00q7r4si0037c0013z00h4m.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F71af63d9p00q7r4si003lc0017i00otm.jpg
在spring-web-mvc.xml中完成mvc:view-controller
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fefa3aff7p00q7r4si004ec0018900nim.jpg
其中这三个页面我们完成以下
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fab7dd6cfp00q7r4si002rc0014q00fsm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F44eb07a4p00q7r4si000cc0009e0091m.jpg
页面代码
Include-head.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F549e889bp00q7r4si002ic0018s00dpm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F51ca96d5p00q7r4si002ac0010x00jnm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F58e6aa38p00q7r4si003lc0012700prm.jpg
Include-nav.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F90b33697p00q7r4si002tc0019500h7m.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F3ac8ca38p00q7r4si003yc0017i00pgm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fe506d0b6p00q7r4si003rc0017n00pmm.jpg
Include-sidebar.jsp
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F9a34df35p00q7r4si0052c0016k00nvm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F723d7f3ep00q7r4si0057c0018300ntm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F71d7fbc7p00q7r4si005jc0019q00oum.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F3ac1fbe4p00q7r4si005hc0018e00qlm.jpg
退出登录
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fba6ee9b9p00q7r4si001ic000tp00e2m.jpg
页面对应的点击位置
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F36395d01p00q7r4si0027c001ah00dfm.jpg
登录检查
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fa665a4e7p00q7r4si001tc000gf00crm.jpg
创建拦截器类
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fea620127p00q7r4si000nc000f2009pm.jpg
完成代码
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F88036217p00q7r4si002wc001bw00jrm.jpg
注册拦截器,配置文件spring-web-mvc.xml
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F43e32f74p00q7r4si003zc0013n00oqm.jpg
测试下
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Ff1b9cd33p00q7r4si000zc0017q00ddm.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2Fdbe8d3f6p00q7r4si000ic000pn0099m.jpg
?url=http%3A%2F%2Fdingyue.ws.126.net%2F2020%2F0325%2F4f7b204cp00q7r4si001pc001gy00fgm.jpg



[size=0.28]特别


回复

使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则


    Archiver|手机版|小黑屋|齐聚无忧 |网站地图

    Powered by Discuz! X3.4  © 2001-2013 Comsenz Inc.