Removing MyFaces Orchestra's “conversationContext” GET parameter from static resources (css, images)

徘徊边缘 提交于 2019-12-10 17:24:46

问题


MyFaces Orchestra adds a ?conversationContext=x to each resource on a page. Since I'm not using the conversation scope for the public part of my project (only for the admin part), I'd like to get rid of that parameter for two reasons:

  • it breaks the browser caching of static resources
  • it's ugly :)

I'm now going to take a look at Orchestra's source-code, and perhaps bypass something, but it would be best if there is an option for this I'm unaware of


回答1:


The answer to that question is simple, and at the same time a bit of a workaround. MyFaces orchestra uses a wrapper around the original HttpServletResponse in order to encode the contesationContext parameter.

There are two options of using Orchestra - with an interceptor (JSF) and a Filter. Both of them try to wrap the response, if it isn't already wrapped. So if both the orchestra Filter and the interceptor are used, the Filter comes firest, wraps the response object, and sets an attribute in the request, which indicates to the interceptor, that it shouldn't wrap the response again.

The Filter can be configured to match a certain URL pattern if conversationContext is to be added. However, for my needs, that pattern matcher was too simple, so I made my own filter instead. So in order to tell the interceptor NOT to wrap the response, all that has to be done is this:

httpRequest.setAttribute(
                RequestParameterServletFilter.REQUEST_PARAM_FILTER_CALLED,
                Boolean.TRUE);


来源:https://stackoverflow.com/questions/1883048/removing-myfaces-orchestras-conversationcontext-get-parameter-from-static-res

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!