Jsf Primefaces组件在会话过期后不响应

Jsf Primefaces组件在会话过期后不响应,jsf,primefaces,Jsf,Primefaces,我有一个检查会话的过滤器。我的过滤器: public class FilterLogin implements Filter{ FilterConfig fc; @Override public void init(FilterConfig filterConfig) throws ServletException { //throw new UnsupportedOperationException("Not supported yet."); //

我有一个检查会话的过滤器。我的过滤器:

public class FilterLogin implements Filter{

    FilterConfig fc;

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        fc = filterConfig;
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

        HttpServletRequest req = (HttpServletRequest) request;
        HttpServletResponse resp = (HttpServletResponse) response;
        HttpSession session = req.getSession(true);

        if (session.getAttribute("loginMB") == null) {
            resp.sendRedirect("/home.xhtml");
        } else {
            chain.doFilter(request, response);
        }  
    }

    @Override
    public void destroy() {
        //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}
web.xml:

<filter>
    <filter-name>filter</filter-name>
    <filter-class>pl.ePrzychodnia.filter.LoginFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>filter</filter-name>
    <url-pattern>/protected/*</url-pattern>
</filter-mapping> 
<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/home.xhtml</location>
</error-page>
我更改:
nav.handleNavigation(fc,null,“/error”)
导航手柄导航(fc,空,“/home”)

但是,当会话超时时,我不会重新检测到home.xhtml页面,只会在单击时转到该页面,我有一个示例错误:

SEVERE: Critical Exception!
javax.faces.application.ViewExpiredException: viewId:/protected/admin/about.xhtml - View /protected/admin/about.xhtml could not be restored.

当我在会话过期时单击“关于页面的引用”时。我看到的是一个不完整的about.xhtml页面,而不是home.xhtml。这就是错误导航在web xml中不起作用的原因。如果操作作为ajax请求调用,则错误将发送到JavaScript回调
onerror

若要在服务器端处理错误,可以向应用程序添加全局异常处理程序。教程是一个很好的遵循


此外,您还可以使用

的功能。您是否收到任何错误消息?哪一个primeface和JSF版本?你可以尝试primefaces在xhtml部分中指出你遇到的问题。我不是说你错了。我只是想了解你的答案,以防将来遇到类似的问题。所以,如果我听起来像是,请原谅我。
onerror
函数在ajax出现问题时调用?这与导航有什么关系?你能解释一下吗?我使用第一种方法全局异常处理,但我有一个小问题。我编辑了我的第一篇文章。你的问题似乎与现在的第一篇完全不同,这使得我的答案毫无价值。我的回答对于面临同样问题的更多用户来说毫无意义。当你的问题改变时,请再问一个问题@橙色91我很高兴你解决了。
SEVERE: Critical Exception!
javax.faces.application.ViewExpiredException: viewId:/protected/admin/about.xhtml - View /protected/admin/about.xhtml could not be restored.