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

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

JSF Ajax請求中的異常處理

JSF Ajax請求中的異常處理

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

2 回答

?
天涯盡頭無女友

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊

OmniFaces FullAjaxExceptionHandler展示柜中充實(shí)了這個(gè)問題。


基本上,您需要創(chuàng)建一個(gè)定制,ExceptionHandler因?yàn)闃?biāo)準(zhǔn)JSF不會提供一個(gè)定制的定制(至少不是明智的選擇)。在其中,您將可以接觸Exception引起所有麻煩的實(shí)例。


這是一個(gè)啟動示例:


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;

    }


}

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


public class YourExceptionHandlerFactory extends ExceptionHandlerFactory {


    private ExceptionHandlerFactory parent;


    public YourExceptionHandlerFactory(ExceptionHandlerFactory parent) {

        this.parent = parent;

    }


    @Override

    public ExceptionHandler getExceptionHandler() {

        return new YourExceptionHandler(parent.getExceptionHandler());

    }


}

需要進(jìn)行以下注冊faces-config.xml:


<factory>

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

</factory>


查看完整回答
反對 回復(fù) 2019-11-04
  • 2 回答
  • 0 關(guān)注
  • 591 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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