0
@WebFilter(filterName = "loginFilter", value = { "/faces/kosz.xhtml" } , dispatcherTypes = { DispatcherType.FORWARD, DispatcherType.ERROR, DispatcherType.REQUEST, DispatcherType.INCLUDE } )
public class loginFilter implements Filter {
public loginFilter(){
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException{
HttpServletRequest req = (HttpServletRequest) request;
userSession auth = (userSession) req.getSession().getAttribute("user");
if (auth != null && auth.isLogged()) {
chain.doFilter(request, response);
HttpServletResponse res = (HttpServletResponse) response;
res.sendRedirect(req.getContextPath() + "/login.xhtml");
}
else {
HttpServletResponse res = (HttpServletResponse) response;
res.sendRedirect(req.getContextPath() + "/login.xhtml");
}
}
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void destroy()
{
throw new UnsupportedOperationException("Not supported yet.");
}
/**
* Return the filter configuration object for this filter.
}
문제는 필터가 실행되지 않는다는 것입니다. URL은 localhost:8080/PP2/faces/kosz.xhtml
입니다. 이것을하기위한 적절한 방법은 무엇입니까? 내 web.xml에는 항목이 없습니다. 모두 Annotations를 기반으로합니다.JSF 필터가 실행되지 않았습니다.
어디에서 필터 템플릿을 가져 왔습니까? 이러한 모든 UnsupportedOperationException은 완전히 잘못되었습니다. 그러나 나는 이것을 몇 번 전에 보았던 것을 기억합니다. 아마도 당신은 웹 사이트 나 책의 어딘가에서 그것을 발견했을 것입니다. 그렇다면 어느 것입니까? – BalusC
Netbeans가 생성합니다. – user1997553
정말요? 와우. 따라서'doPost()'와'doGet() '이 완전히 같은'processRequest()'메소드에 위임하는 서블릿을 생성 할뿐만 아니라 그와 같은 깨진 필터를 생성한다. – BalusC