繁体   English   中英

@Intertceptors不适用于JSF页面的Web bean

[英]@Intertceptors does not work for web bean for JSF page

@Named
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
    public String methodThrowException throws Exception() {
        throws new Exception();
    }
}

public class MyInterceptor {
    @AroundInvoke
    public Object intercept(InvocationContext ic) throws Exception {
        try {
            return ic.proceed();
        } catch (Exception e) {
            return null;
        }
    }
}

对于@Stateless Bean,拦截器有效 ,但对于BeanWeb拦截器,无效 而且我们从未进入过“拦截”方法。

  1. 为什么会这样呢?
  2. 如何拦截BeanWeb中的方法调用?

PS:在Glassfish 3.x下,所有这些旋转。

是工作:

@Named
@Stateful
@ConversationScoped
@Interceptors(MyInterceptor.class)
public class BeanWeb implements Serializable {
    public String methodThrowException throws Exception() {
        throws new Exception();
    }
}

public class MyInterceptor implements Serializable {
    @AroundInvoke
    public Object intercept(InvocationContext ic) throws Exception {
        try {
            return ic.proceed();
        } catch (Exception e) {
            return null;
        }
    }
}

我希望这是正确的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM