私のプロジェクトでday CQを使用してフィルターを開発しているときに問題に直面しています。私のコードは requestDispatcher の forward メソッドで動作しています。しかし、response.sendRedirect() では機能しません。
if (servletRequest instanceof SlingHttpServletRequest) {
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
String uri = httpRequest.getRequestURI();
if(uri.startsWith("/content")){
Cookie[] cookies = httpRequest.getCookies();
boolean found = false;
for (Cookie cookie : cookies) {
log.info("Cookies in filter: " + cookie.getName());
if("LtpaToken2".equals(cookie.getName())){
log.info("LTPA token found ");
found = true;
break;
}
}
if(found){
filterChain.doFilter(servletRequest, servletResponse);
}
else{
httpResponse.sendRedirect("http://www.google.com");
}
}else{
filterChain.doFilter(servletRequest, servletResponse);
}
log.info("Message URL ::"+httpRequest.getRequestURL().toString());
log.info("URI ::"+uri);
}
だから私の問題を解決してください、それは非常にありがたいです。
よろしく Narsi p