3
最近我們在spring 3.2中使用servlet 3.0中的異步功能,但是我們的ShallowEtagHeaderFilter根本無效,我認爲它必須是框架刷新響應在我的內容被處理之前... 如何解決它?任何人都有經驗?當我使用異步servlet(spring 3.2)時,Spring的ETag過濾器不起作用
最近我們在spring 3.2中使用servlet 3.0中的異步功能,但是我們的ShallowEtagHeaderFilter根本無效,我認爲它必須是框架刷新響應在我的內容被處理之前... 如何解決它?任何人都有經驗?當我使用異步servlet(spring 3.2)時,Spring的ETag過濾器不起作用
在Spring 4.3.5參考ShallowEtagFilter的代碼片段,
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
HttpServletResponse responseToUse = response;
if (!isAsyncDispatch(request) && !(response instanceof ContentCachingResponseWrapper)) {
responseToUse = new HttpStreamingAwareContentCachingResponseWrapper(response, request);
}
filterChain.doFilter(request, responseToUse);
if (!isAsyncStarted(request) && !isContentCachingDisabled(request)) {
updateResponse(request, responseToUse);
}
}
/**
* Whether request processing is in asynchronous mode meaning that the
* response will not be committed after the current thread is exited.
* @param request the current request
* @since 3.2
* @see WebAsyncManager#isConcurrentHandlingStarted()
*/
protected boolean isAsyncStarted(HttpServletRequest request) {
return WebAsyncUtils.getAsyncManager(request).isConcurrentHandlingStarted();
}
當您使用異步servlet時,病情就不會得到滿足,這意味着產生ETAG的業務邏輯就不會被調用。