使用了
<global-results>
<result name="error">/chapterFour/Error.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="error" />
</global-exception-mappings>
<action name="wrongTest" class="myInterceptorStruts.WrongTest"></action>
之后就只能在网页上打印异常信息了, 如何修改xml能同时在控制台上也打印出错误信息?
我的抛出异常类的代码如下:
public class WrongTest extends ActionSupport
{
@Override
public String execute() throws Exception
{
throw new Exception("hello exception") ;
}
}
访问action之后就在网页上面抛出异常, 控制台则没有异常信息的打印:
如何在控制台中也输出异常和打印栈信息呢?
<interceptors>
<interceptor-stack name="defaultStackWithLogEnabled">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">error</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="defaultStackWithLogEnabled" />
我看了下文档和源码才明白logLevel
的debug
原来不会在控制台上面输出, 要调到error才行, 早明白的话就不用发出来了, 麻烦大家了