小编dra*_*ake的帖子

如何全局捕获错误,记录它们并在J2EE应用程序中向用户显示错误页面

我在google上搜索了这个主题并看到了一些最佳实践.但我需要一些具体的建议.我正在开发一个J2EE应用程序,它有来自JSP的servlets/Struts2 /对DAO的调用.所以应用程序是各种搞砸了.大多数数据是通过存储过程获取的,这些存储过程由iBatis ORM/Spring调用.有时当SP端发生错误时,它会向用户显示一条丑陋的消息,如下所示:

javax.servlet.ServletException: org.springframework.jdbc.BadSqlGrammarException: SqlMapClient operation; bad SQL grammar []; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in debtowed.xml.  
--- The error occurred while applying a parameter map.  
--- Check the debtowed.getFormerTenantData.  
--- Check the statement (update procedure failed).  
--- Cause: java.sql.SQLException: ORA-06550: line 1, column 11:
PLS-00905: object package.GET_FORMER_ADDRESS is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Caused by: java.sql.SQLException: ORA-06550: line 1, column 11:
PLS-00905: object package.GET_FORMER_ADDRESS is invalid
ORA-06550: line 1, column 7: …
Run Code Online (Sandbox Code Playgroud)

error-handling logging java-ee ora-06550

1
推荐指数
1
解决办法
4466
查看次数

这是可能的java或任何其他编程语言

public abstract class Master
{
    public void printForAllMethodsInSubClass()
    {
        System.out.println ("Printing before subclass method executes");
            System.out.println ("Parameters for subclass method were: ....");
    }
}

public class Owner extends Master {
    public void printSomething () {
        System.out.println ("This printed from Owner");
    }

    public int returnSomeCals ()
    {
        return 5+5;
    }
}
Run Code Online (Sandbox Code Playgroud)

不搞乱子类的方法......是否可以printForAllMethodsInSubClass()在子类的方法执行之前执行?

更新:

使用AspectJ/Ruby/Python ......等是否也可以打印参数?以上代码格式如下:

public abstract class Master
{
    public void printForAllMethodsInSubClass()
    {
        System.out.println ("Printing before subclass method executes");

    }
}

public class Owner extends Master {
    public …
Run Code Online (Sandbox Code Playgroud)

java programming-languages

0
推荐指数
1
解决办法
337
查看次数