移除MyFaces乐团的"conversationContext"从静态资源(css,图像)获取参数 [英] Removing MyFaces Orchestra's "conversationContext" GET parameter from static resources (css, images)

查看:101
本文介绍了移除MyFaces乐团的"conversationContext"从静态资源(css,图像)获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MyFaces Orchestra将?conversationContext=x添加到页面上的每个资源.由于我没有在项目的公共部分(仅用于管理部分)使用对话作用域,因此出于以下两个原因,我想摆脱该参数:

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:

  • 它破坏了浏览器对静态资源的缓存
  • 这很丑:)

我现在要看一下Orchestra的源代码,也许绕过一些东西,但是最好有一个我不知道的选项

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

推荐答案

该问题的答案很简单,同时也有一些解决方法. MyFaces乐队使用原始HttpServletResponse周围的包装器来对contesationContext参数进行编码.

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.

使用Orchestra有两种选择-带有拦截器(JSF)和Filter. 他们都尝试包装响应,如果尚未包装,则为 .因此,如果同时使用乐团Filter和拦截器,则Filter会启动,包装响应对象,并在请求中设置一个属性,该属性指示拦截器不要再次包装响应.

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.

如果要添加conversationContext,则可以将Filter配置为匹配某个URL模式.但是,出于我的需要,该模式匹配器太简单了,所以我改用了自己的过滤器.因此,为了告诉拦截器不要包装响应,必须要做的就是:

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);

这篇关于移除MyFaces乐团的"conversationContext"从静态资源(css,图像)获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆