[英]How to add Authorization header in redirect (Spring Security)
I am trying to redirect to a URL after certain checks are passed.通过某些检查后,我试图重定向到 URL。
@GetMapping("/verify")
public void verify(HttpServletResponse response) {
response.setHeader("Authorization", "bearer ehxxxxxxxx");
response.sendRedirect("/home");
}
But I am unable to retrieve the Authorization
header at JwtAuthenticationFilter
.但我无法在 JwtAuthenticationFilter 检索
Authorization
JwtAuthenticationFilter
。 (Skipping that code, since it works for other requests). (跳过该代码,因为它适用于其他请求)。
What am I doing wrong?我究竟做错了什么? please help.
请帮忙。
Try this code:试试这个代码:
@GetMapping("/verify")
public void verify(HttpServletResponse response) {
response.setHeader("Authorization", "bearer ehxxxxxxxx");
RequestDispatcher view = request.getRequestDispatcher("/home");
view.forward(request, response);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.