2009-02-06 62 views

回答

1

在速度這是我如何解決了這個問題。

 
#foreach ($i in [1..3])  
    #if($exception.Cause) 
      #set($exception = $exception.Cause) 
      #foreach($stack in $exception.getStackTrace()) 
       $stack.toString() 
      #end  
    #end 
#end 
0

如果你想在輸出中顯示跟蹤,你可以在try-catch-finally塊中包裝evaluate方法。在catch中,寫入堆棧跟蹤或僅寫入作者的異常消息。在最後部分只需刷新作者。

事情是這樣的,如果我沒記錯的話:

StringWriter w = new StringWriter(); 
try { 
    Velocity.evaluate(context, w, "mystring", s); 
} catch (Exceptions... e) 
    w.write(e.getMessage()); 
} finally { 
    w.flush(); 
} 
+0

我想在測試開發模式下啓用的html頁面顯示異常。但是在生產模式下,交換機自動不顯示錯誤。 此解決方案不適合我的情況。 – 2009-02-09 18:45:13