如何在JBoss Seam中添加自定义过滤器

时间:2011-03-24 19:34:05

标签: seam seam2 servletexception

我是JBoss Seam的新手。我一直在处理一个小项目的问题。该项目有一些错误,不幸的是,我无法找出错误的确切原因。我得到一个javax.servlet.ServletException。请有人告诉我如何添加自定义过滤器,以便我能够正确捕获错误。

1 个答案:

答案 0 :(得分:2)

如果你想在Seam中发生trap所有同步异常,你可以扩展Seam中的Exceptions类。

@Name("org.jboss.seam.exception.exceptions")
@Scope(ScopeType.APPLICATION)
@Install(precedence = Install.APPLICATION)
@BypassInterceptors
@Transactional
public class ExceptionHandler extends Exceptions {

    private static final LogProvider log = Logging.getLogProvider(ExceptionHandler.class);

    public void handle(Exception ex) throws Exception {
         //Here you can do whatever you want with the exception
         log.error("Exception occurred : " + ex.getMessage());
         super.handle(ex);
    }