我在java web中有AccessFilter問題。當我調用/main.jspx時,它將重定向到login.jsp。但是,當我試圖登錄某些錯誤出現會話過濾器重定向問題
public class AccessFilter implements Filter {
private FilterConfig filterConfig;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpSession session = ((HttpServletRequest) request).getSession();
HttpServletResponse res = (HttpServletResponse) response;
Client client = (Client) session.getAttribute("client");
if (client != null) {
chain.doFilter(request, response);
} else {
RequestDispatcher dispatcher = request.getRequestDispatcher(
ConfigurationManager.getInstance().getProperty(ConfigurationManager.LOGIN_PAGE_PATH));
dispatcher.forward(request, response);
}
}
@Override
public void destroy() {
this.filterConfig = null;
}
}
的web.xml:
<filter>
<filter-name>AccessFilter</filter-name>
<filter-class>ua.kpi.shop.filter.AccessFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AccessFilter</filter-name>
<url-pattern>/jsp/main.jspx</url-pattern>
<url-pattern>/jsp/pokemons.jspx</url-pattern>
</filter-mapping>
錯誤: HTTP狀態404 - /PokemonsShop/login.jspx
類型的現狀報告
消息/ PokemonsShop/login.jspx
description請求的資源不可用。
通常情況下,在您的服務器輸出中,您將具有未找到文件的完整本地路徑,您將能夠找到我確定存在的問題。 –