今天遇到標題中的怪問題,跟蹤了一下源代碼,發現有那麼一句: html
if (filterAlreadyAppliedForRequest(request)) { // Prior to Servlet 2.4 spec, it was unspecified whether the filter should be called again upon an include(). chain.doFilter(request, response); return; }
private boolean filterAlreadyAppliedForRequest(HttpServletRequest request) { if (request.getAttribute(ALREADY_APPLIED_KEY) == Boolean.TRUE) { return true; } else { request.setAttribute(ALREADY_APPLIED_KEY, Boolean.TRUE); return false; } }
再搜了一下相關的錯誤,其中的一個解決方案就是寫一個filter,地dispatcher爲ERROR的時候,清除已經煊染標識, java
HttpServletRequest request = (HttpServletRequest) servletRequest; request.removeAttribute("com.opensymphony.sitemesh.APPLIED_ONCE"); chain.doFilter(servletRequest, servletResponse);問題就能夠解決了。可是對於正常forward的跳轉,卻沒有生效。
下班了,先回家,晚上回去研究一下,爲何?若是解決,下篇博客會標註一下。 spa