爲了提供正確的瀏覽器緩存,我想擺脫conversationContext
參數,即Apache MyFaces Orchestra添加到每個請求中,以便請求到css文件。如何刪除靜態資源的Orchestra轉換上下文參數?
由於Bozho建議,我已經實現了一個設置Orchestra正在查找的屬性的過濾器。
public class ResourceFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse theResponse, FilterChain theChain) throws IOException, ServletException {
if(shouldNotAppendConversation(request)) {
request.setAttribute(RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED, Boolean.TRUE);
}
theChain.doFilter(request, theResponse);
}
private boolean shouldNotAppendConversation(ServletRequest theRequest) {
HttpServletRequest aRequest = (HttpServletRequest) theRequest;
String aPath = aRequest.getRequestURI();
if(aPath.endsWith(".css.jsf")) {
return true;
}
return false;
}
@Override
public void init(FilterConfig theFilterConfig) throws ServletException {
}
@Override
public void destroy() {
}
}
這不起作用的參數仍然附加到每個請求。在調試時,我發現過濾器首先被jsf網站的請求命中。當然,我想在該請求中包含conversation context
,因此過濾器會將請求直接轉發到鏈中的下一個過濾器。點擊過濾器的下一個請求(通常是對css文件的請求)已經包含在請求中的conversation context
。
奇怪的是,如果我修改過濾器到總是設置屬性,所有的請求將不會有conversation context
屬性。但這意味着,conversation context
也不包括在jsf網站的請求中(但應該)。
我注意到,在生成的jsf網站的HTML鏈接到CSS文件也包含conversation context
屬性或不依賴於過濾器的實現。我想這是因爲第二個請求已經包含了conversation context
參數?
我不明白爲什麼Orchestra會將conversation context
參數附加到每個請求上,而不僅僅是未設置屬性的請求。
如何實現過濾器正常工作?