




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、第式:使用jsp展示2、第二種方式:網(wǎng)頁靜態(tài)化使 創(chuàng)建一個(gè)模板,類似于jsp使用nginxSSOSingleSignOn,單點(diǎn)登錄。SSO是在多個(gè)應(yīng)用系統(tǒng)中,用戶只需要登錄一次名2000~3000一個(gè)tomcat反 服不要超過5個(gè)。Redis使用模擬依賴的jar<<project""<!--Spring--Redis 整合ssmDao詢條件,到tb_user中進(jìn)行查詢?nèi)绻樵兊浇Y(jié)果返回false,查詢結(jié)果為空返回true。InttypepublicpublicclassRegisterServiceImplimplementsRegisterServiceprivateprivateTbUserMappercheckData(Stringparam,inttype)TbUserExampleexample=newTbUserExample();Criteriacriteria=if(1==type)}elseif(2=={}elseif(3==type{}List<TbUser>list=if(list==null||list.isEmpty())}}}returnreturn publicclassRegisterControllerprivateRegisterService checkData(@PathVariableStringparam,@PathVariableIntegertype,String{trytryTaotaoResultresult=registerService.checkData(param, JacksonValuemap JacksonValue=newMap return }}catch(Exception{}}}returnTaotaoResult.build(500,return返回state為400,如果校驗(yàn)成功執(zhí)行插入操作,完成后返回TaotaoResult.okDao<p>Title:<p><p>Description:@param@seepublicTaotaoResultregister(TbUseruser) if 不能為空}TaotaoResultresult=checkData(user.getUsername(),if(!(boolean)result.getData())returnTaotaoResult.build(400"用戶名重復(fù)} if(user.getPhone()!=null)result=checkData(user.getPhone(),if(!(boolean)result.getData()), 號重復(fù)}} if ()!=null)result=(),if(!(boolean)result.getData())returnTaotaoResult.build(400"郵箱重復(fù)}}return}publicTaotaoResultregister(TbUseruser)tryTaotaoResultresult=return}catch(Exception{}}3、生成token4redis,key就是token5、把token寫入。6、返回登錄成功需要把tokenDaoServicepublicclassLoginServiceImplimplementsLoginServiceprivateTbUserMapperuserMapper;privateJedisjedisprivateStringREDIS_SESSION_KEY;privateIntegerpublicTaotaoResultlogin(Stringusername,Stringpassword,HttpServletRequestrequest,HttpServletResponseresponse){TbUserExampleexample=newTbUserExample();Criteriacriteria=example.createCriteria();List<TbUser>list=if(list==null||list.isEmpty())returnTaotaoResult.build(400,"用戶名或錯(cuò)誤}TbUseruser=returnTaotaoResult.build(400,"用戶名或錯(cuò)誤} =//value:userjsonjedis.set(REDIS_SESSION_KEY+":"+token,jedis.expire(REDIS_SESSION_KEY+":"+token,寫Utils.set(request,response,"TT_TOKEN",returnreturn}}publicclassLoginControllerprivatepublicclassLoginControllerprivateLoginService publicTaotaoResultlogin(Stringusername,StringHttpServletRequestresponse)tryTaotaoResultresult=loginService.login(username,password,request,return}catch(Exceptione)returnTaotaoResult.build(500,}}}通過tokentoken到redissession400并session已經(jīng)過期。如果查詢到用戶,返回用戶信息,并且更新一下用戶的過期時(shí)請求使用 參數(shù):String根據(jù)token查詢r(jià)edispublicpublicTaotaoResultgetUserByToken(Stringtoken)Stringjson=.get(REDIS_SESSION_KEY+":"+if(StringUtils.isBlank(json))}TbUseruser=JsonUtils.jsonToPojo(json,.expire(REDIS_SESSION_KEY+":"+token,return}url中取token的內(nèi)容,調(diào)用ServiceTaotaoResult(json數(shù)據(jù) getUserByToken(@PathVariableStringtoken,Stringcallback)tryTaotaoResultresult= JacksonValuemap JacksonValue=newMap return }}catch(Exception{}}returnTaotaoResult.build(500,return6功能實(shí)publicclassPageController publicStringshowLogin()return} publicStringshowRegister()return}}1、用戶頁面輸入信息,要對數(shù)據(jù)的有效性進(jìn)行檢查??梢哉{(diào)用sso系統(tǒng)的接口判斷數(shù)參考jsp實(shí)現(xiàn)。1、請求2、從中取3、如果沒有toke5、如果用戶sessionreturnreturnreturnreturnreturnreturnreturnreturn;;publicpublicclassLoginInterceptorimplementsHandlerInterceptorprivateString throwsException//1 TbUseruser=userService.getUserByToken(request,if(user=={}}publicvoidpostHandle(HttpServletRequestrequest,HttpServletResponseresponse,Objecthandler,ModelAndViewmodelAndView)throwsExcep
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 分批注資合同范本
- 廠家授權(quán)生產(chǎn)合同范本
- 縣城酒吧轉(zhuǎn)讓合同范本
- 公司參股合同范本
- 制模合同范本
- 單筆運(yùn)費(fèi)結(jié)算合同范本
- 修河床合同范本寫
- gps監(jiān)控合同范本
- 印刷設(shè)備轉(zhuǎn)讓合同范本
- 上虞天然氣公司合同范本
- 2024年新疆維吾爾自治區(qū)專升本考試大學(xué)政治測試題含解析
- 邊坡噴錨施工工藝
- 2016-2023年婁底職業(yè)技術(shù)學(xué)院高職單招(英語/數(shù)學(xué)/語文)筆試歷年參考題庫含答案解析
- 海鮮酒樓營銷策劃方案
- 電能計(jì)量裝置配置規(guī)范
- 有償義工招募方案
- 冬春季節(jié)傳染病防控(流感)
- 潛在供應(yīng)商審核報(bào)告模版13-02
- 《臨床疾病概論》課件
- 安全生產(chǎn)費(fèi)用使用臺賬
- 舞臺設(shè)計(jì)課件
評論
0/150
提交評論