第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JSF Ajax請求中的異常處理

JSF Ajax請求中的異常處理

處理JSF ajax請求時引發(fā)異常時,如何處理異常并訪問堆棧跟蹤?現(xiàn)在,當JSF項目階段設(shè)置為Development時,我僅在JavaScript警報中獲得異常類名稱和消息。更糟糕的是,當JSF項目階段設(shè)置為Production時,沒有任何視覺反饋,并且服務器日志不顯示有關(guān)異常的任何信息。如果相關(guān),那么我在Netbeans中使用GlassFish。
查看完整描述

2 回答

?
天涯盡頭無女友

TA貢獻1831條經(jīng)驗 獲得超9個贊

OmniFaces FullAjaxExceptionHandler展示柜中充實了這個問題。


基本上,您需要創(chuàng)建一個定制,ExceptionHandler因為標準JSF不會提供一個定制的定制(至少不是明智的選擇)。在其中,您將可以接觸Exception引起所有麻煩的實例。


這是一個啟動示例:


public class YourExceptionHandler extends ExceptionHandlerWrapper {


    private ExceptionHandler wrapped;


    public YourExceptionHandler(ExceptionHandler wrapped) {

        this.wrapped = wrapped;

    }


    @Override

    public void handle() throws FacesException {

        FacesContext facesContext = FacesContext.getCurrentInstance();


        for (Iterator<ExceptionQueuedEvent> iter = getUnhandledExceptionQueuedEvents().iterator(); iter.hasNext();) {

            Throwable exception = iter.next().getContext().getException(); // There it is!


            // Now do your thing with it. This example implementation merely prints the stack trace.

            exception.printStackTrace();


            // You could redirect to an error page (bad practice).

            // Or you could render a full error page (as OmniFaces does).

            // Or you could show a FATAL faces message.

            // Or you could trigger an oncomplete script.

            // etc..

        }


        getWrapped().handle();

    }


    @Override

    public ExceptionHandler getWrapped() {

        return wrapped;

    }


}

為了使其運行,請ExceptionHandlerFactory如下創(chuàng)建一個自定義:


public class YourExceptionHandlerFactory extends ExceptionHandlerFactory {


    private ExceptionHandlerFactory parent;


    public YourExceptionHandlerFactory(ExceptionHandlerFactory parent) {

        this.parent = parent;

    }


    @Override

    public ExceptionHandler getExceptionHandler() {

        return new YourExceptionHandler(parent.getExceptionHandler());

    }


}

需要進行以下注冊faces-config.xml:


<factory>

    <exception-handler-factory>com.example.YourExceptionHandlerFactory</exception-handler-factory>

</factory>


查看完整回答
反對 回復 2019-11-04
  • 2 回答
  • 0 關(guān)注
  • 599 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號