2012-12-16 3 views
0

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

설명 요청한 리소스를 사용할 수 없습니다.

+0

일반적으로 서버 출력에는 파일의 전체 로컬 경로가 없으므로 확실한 문제가 무엇인지 찾을 수 있습니다. –

답변

0

filterConfig.getServletContext().getRequestDispatcherrequest-getRequestDispatcher과 반대되는 절대 경로를 사용합니다. 그것이 해결책이든간에 나는 말할 수 없다.

+0

이것은 도움이되지 않습니다. – Proof

0

메시지를 볼 때 두 가지가 내 머리 속으로 들어 왔습니다. 1) 클라이언트 개체가 null인지 아닌지 확인 했습니까? 로그인 액션 (메소드)을 실행할 때 클라이언트를 세션으로 올바르게 설정하지 않을 수 있습니까? 2) 서버 오류에서 "찾을 수 없습니다 /PokemonsShop/login.jspx"라고 표시되지만 필터 매핑에서/jsp/xxx를 언급하고 있습니다. 로그인 페이지가 jsp 폴더에 있고 필터에있는 /PokemonsShop/login.jspx로 리디렉션하고 있기 때문에 액세스 할 수있는 webapp 루트 폴더 아래에 있어야합니다. 그들 중 하나가 도움이되기를 바랍니다