restTemplate學習
BasicAuthenticationInterceptor
攔截器 | 功能 |
---|---|
ClientHttpRequestInterceptor | 請求攔截器接口,是一個函數式接口 |
BasicAuthenticationInterceptor | 實現了ClientHttpRequestInterceptor,應用給定的HTTP基本身份驗證,用戶名/密碼對。 |
請求攔截器:對請求之前進行一些操作
restTemplate調用BasicAuthenticationInterceptor(默認沒有調用,需要指定)
自定義攔截器
實現ClientHttpRequestInterceptor
加入配置
接口獲取header
自定義異常例子源碼地址