imooc SpringBoot高階之Web高階

2021-10-02 14:56:39 字數 2102 閱讀 1860

將通用邏輯從業務邏輯中分離出來

@before註解:在方法執行之前執行

@after註解:在方法執行之後執行

}@pointcut註解:設定切點,在其他攔截中直接呼叫log()方法

}記日誌建議採用logger類中的幾個級別,而不是直接列印在控制台

}記錄一次http請求及處理結果

//記錄http請求的內容

@before

("log()"

)public

void

dobefore

(joinpoint joinpoint)

",request.

getrequesturl()

);//method

logger.

info

("method={}"

,request.

getmethod()

);//ip

logger.

info

("ip={}"

,request.

getremoteaddr()

);//類方法

logger.

info

("class_method={}"

,joinpoint.

getsignature()

.getdeclaringtypename()

+"."

+joinpoint.

getsignature()

.getname()

);//引數

logger.

info

("args={}"

,joinpoint.

getargs()

);}//記錄http請求後,伺服器返回的結果

@afterreturning

(returning =

"object"

,pointcut =

"log()"

)public

void

doafterreturning

(object object)

",object.

tostring()

);}}統一異常處理

測試service

測試api

@runwith

(springrunner.

class

)@springboottest

@autoconfiguremockmvc

public

class

luckymoneycontrollertest

}

Spring Boot高階之Web高階

1 使用aop處理請求 springboot使用aop處理請求 將 before和 after中的路徑屬性提取出來 將通用的路徑提取出來 pointcut execution public com.hytxwz.girl.controller.public void log before log p...

攻防世界WEB高階之unserialize3

難度係數 1星 題目描述 暫無 題目僅僅給出了乙個場景開啟場景看到了如下內容 class xctf code 通過分析在瀏覽器位址框輸入 位址 code 0,發現0出現在code後面。所以我們輸入的字段會直接傳到code中。根據題給的資訊unserialize,序列化操作我們聯想到序列化函式 ser...

攻防世界web高階區之unfinish

題目 from bs4 import beautifulsoup html解析器 defgetdatabase database for i in range 10 data database 註冊 requests.post data database login data response re...