HttpServletResponse获取请求头token
时间: 2023-10-09 21:12:30 浏览: 97
Http请求头和响应头
要获取HttpServletResponse中的请求头token,可以使用response.getHeader("Authorization")方法。这个方法会返回请求头中名为"Authorization"的值,也就是token的值。在上述提供的后端代码中,可以看到在校验邮箱登录的code时,如果校验成功,会通过response.addHeader("Authorization", encodeToken)将token添加到响应头中。所以在后续的请求中,可以通过response.getHeader("Authorization")来获取请求头中的token值。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [解决拦截器对ajax请求的拦截实例详解](https://download.csdn.net/download/weixin_38639237/14902168)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [前端获取请求头中的数据(token等)](https://blog.csdn.net/java_Zyk/article/details/122710178)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文