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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

拋出一個(gè) Error resolving template template might not exist or might not be accessible 的異常

在ajax的異常處理中,直接返回IMoocJSONResult是不行的,會(huì)再拋出一個(gè)

Error resolving template template might not exist or might not be accessible 的異常,而不是我們預(yù)想的byZero的異常,這時(shí)候需要使用MappingJackson2HttpMessageConverter把IMoocJSONResult手動(dòng)寫入 HttpServletResponse中。

?

private static final String ERROR_VIEW = "error";

@Autowired

private MappingJackson2HttpMessageConverter jsonConverter;

???

@ExceptionHandler(value = Exception.class)

public Object error(HttpServletRequest request, HttpServletResponse response, Exception e) throws HttpMessageNotWritableException, IOException {

if(isAjax(request)) {

MyJSONResult result = MyJSONResult.errorException(e.getMessage());

??????????? jsonConverter.write(result, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response));

??????????? return null;

} else {

ModelAndView mav = new ModelAndView();

mav.addObject("exception",e);

mav.addObject("url", request.getRequestURL());

mav.setViewName(ERROR_VIEW);

return mav;

}

}


正在回答

13 回答

學(xué)了了,我就說我的代碼一模一樣,結(jié)果缺不一樣

0 回復(fù) 有任何疑惑可以回復(fù)我~

一群人自以為懂了,瞎帶節(jié)奏

0 回復(fù) 有任何疑惑可以回復(fù)我~

大佬牛逼,我還郁悶為啥視頻的跑得起來呢,還特意從github下載了源碼

0 回復(fù) 有任何疑惑可以回復(fù)我~

盡信書不如無書,這哥們的是對(duì)的。

0 回復(fù) 有任何疑惑可以回復(fù)我~

老師的雖然跑起來了,但是alert輸出的結(jié)果不對(duì),然后就不講了,這哥們的才是對(duì)的。

0 回復(fù) 有任何疑惑可以回復(fù)我~
@RestControllerAdvice

試試

0 回復(fù) 有任何疑惑可以回復(fù)我~

https://img1.sycdn.imooc.com//5be6a23500011ddf13510426.jpg這個(gè)是我的ajax

0 回復(fù) 有任何疑惑可以回復(fù)我~

我能成功啊 不知道你這個(gè)異常怎么來的

0 回復(fù) 有任何疑惑可以回復(fù)我~

學(xué)習(xí)了,但是不知道為啥老師的代碼能夠跑成功,我反復(fù)看了幾遍以為他加了什么特殊配置,然而并沒有找到。。。

0 回復(fù) 有任何疑惑可以回復(fù)我~

你是對(duì)的。。。


0 回復(fù) 有任何疑惑可以回復(fù)我~
首頁上一頁12下一頁尾頁

舉報(bào)

0/150
提交
取消

拋出一個(gè) Error resolving template template might not exist or might not be accessible 的異常

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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