检查条件后,如果条件失败,然后使用请求调度程序将其重定向到其他页面。它正在重定向到该页面,但 css 未应用于该页面。为什么会这样?
public class RolePrivilegeFilter implements Filter {
List<String> privilege = null;
private static final String notAuthorizedPath = "/home/notAuthorized.jsf";
@Override
public void destroy() {
log.info("filter finish");
}
@Override
public void doFilter(ServletRequest sRequest, ServletResponse sResponse, FilterChain filterChain) throws IOException, ServletException {
String smUser = null;
try {
HttpServletRequest request = (HttpServletRequest) sRequest;
HttpServletResponse response = (HttpServletResponse) sResponse;
HttpSession session = null;
try {
request = (HttpServletRequest) sRequest;
smUser = request.getHeader(EnvironmentBean.SESSION_ATTR_SM_USER);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
if (rolePrivilege == null || rolePrivilege.isEmpty()) {
rolePrivilege = new RolePrivilegeBuilderImpl().rolePrivilege("Smtest2");
privilege filter bean is\t"+rolePrivilege);
log.debug("After rolePrivilege: " + rolePrivilege);
if (rolePrivilege != null && rolePrivilege.size() > 0 ) {
if (session == null) {
session = request.getSession(true);
}
session.setAttribute("privilege", rolePrivilege);
} else {
//This is the page iam redirecting to.
System.out.println("role privilege not authorized page");
RequestDispatcher rd = request.getRequestDispatcher(notAuthorizedPath);
rd.forward(request, response);
return;
}
} catch (Exception e) {
e.printStackTrace();
log.debug("Error in setting session attribute: " + e.getMessage());
}
log.debug("doFilter() finish");
filterChain.doFilter(sRequest, sResponse);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
log.info("filter start");
}
}
问题是 iam 重定向到该页面,但该页面的 css 没有被应用,就像没有显示背景图像一样。为什么会这样?