ZK 主题和 IE 行为 (.htc) 内容类型的问题

发布于 11-04 14:40 字数 1811 浏览 9 评论 0原文

基本问题

有没有办法设置 jar 中拉入 ZK 主题的元素的 mime 类型(内容类型)?

扩展背景(已发布到 ZK 论坛,但没有回复)

我们正在为我们的应用程序构建一个主题 .jar,并且我已经使用 zkTheme.bat 使一切工作得很好。然而,我遇到的问题是我们正在使用 PIE.htc (http://www.css3pie.com) 以便为 IE 7 和 IE 8 提供 CSS3 功能(特别是圆角、渐变和框阴影)。在主题内链接它的唯一方法是将其指向 jar 内的相关资源,如下所示:

  behavior:url(${c:encodeURL(c:cat3('~./',project,'/PIE.htc'))});

其中 c: 是 core 的命名空间,project 是项目的根目录。这指向正确的文件资源,但标头设置不正确。对文件执行 wget,我们得到以下结果:

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Last-Modified: Thu, 28 Apr 2011 12:36:54 GMT
  Cache-Control: public, max-age=31536000
  Expires: Fri, 27 Apr 2012 12:36:07 GMT
  Content-Type: ;charset=UTF-8
  Content-Language: en-US
  Content-Length: 28284
  Date: Thu, 28 Apr 2011 14:08:23 GMT
  Connection: keep-alive
Length: 28284 (28K) []

如您所见,内容类型为空白。这可能是因为 .jar 中提供的大多数文件都是图像资源,而不是行为文件。如果我们只获取文件本身,我们会得到以下结果。

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Accept-Ranges: bytes
  ETag: W/"28280-1299679133268"
  Last-Modified: Wed, 09 Mar 2011 13:58:53 GMT
  Content-Type: text/x-component
  Content-Length: 28280
  Date: Thu, 28 Apr 2011 14:10:34 GMT
  Connection: keep-alive
Length: 28280 (28K) [text/x-component]

因此,根本问题是 Internet Explorer 无法看到“text/x-component”的内容类型标头,因此无法利用 .htc 内的代码来正确解析 CSS。因此,我的问题是:有没有办法让 zk 从 .jar 中提供此文件作为正确的内容类型?环顾四周的配置,我没有找到一种方法来做到这一点。另外,我找不到支持从 theme.jar 中提取的底层代码,以便更改代码来找出此内容类型。我意识到我可以将 PIE.htc 放在网络服务器上的某个位置并指向主题 jar 之外的它,但这使得该代码的可移植性大大降低,因此消除了我们使用主题 jar 的逻辑的相当大一部分。

请注意:我们在 Tomcat 上提供此服务,并且我已经检查了 web.xml 以确保 text/x-component 已绑定(这显然是这种情况,否则第二个 wget 将不会有原来它做了什么)。

BASIC QUESTION:

Is there a way to set the mime-type (content-type) of elements inside a jar that are pulled into a ZK theme?

Extended background (already posted to ZK Forums with no response)

We are building a theme .jar for our application, and I have gotten everything to work pretty well using zkTheme.bat. The problem I'm having, however, is that we are using PIE.htc (http://www.css3pie.com) in order to provide CSS3 capabilities to IE 7 and IE 8 (specifically just rounded corners, gradients, and box-shadow). The only way to link this inside the theme is to point it to the relative resource inside the jar like so:

  behavior:url(${c:encodeURL(c:cat3('~./',project,'/PIE.htc'))});

where c: is the namespace for core, and project is the root directory of the project. This points to the correct file resource, but the header is not being set correctly. Doing a wget on the file, we get the following:

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Last-Modified: Thu, 28 Apr 2011 12:36:54 GMT
  Cache-Control: public, max-age=31536000
  Expires: Fri, 27 Apr 2012 12:36:07 GMT
  Content-Type: ;charset=UTF-8
  Content-Language: en-US
  Content-Length: 28284
  Date: Thu, 28 Apr 2011 14:08:23 GMT
  Connection: keep-alive
Length: 28284 (28K) []

As you can see, the content-type is blank. This is probably because most of the files inside the .jar that are being served up are image resources, not behavior files. Here is what we get if we wget just the file itself.

HTTP request sent, awaiting response...
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Accept-Ranges: bytes
  ETag: W/"28280-1299679133268"
  Last-Modified: Wed, 09 Mar 2011 13:58:53 GMT
  Content-Type: text/x-component
  Content-Length: 28280
  Date: Thu, 28 Apr 2011 14:10:34 GMT
  Connection: keep-alive
Length: 28280 (28K) [text/x-component]

So underlying issue is that Internet Explorer doesn't see the content-type header of "text/x-component" and therefore doesn't utilize the code inside the .htc to parse the CSS correctly. My question is therefore: is there a way to make zk serve up this file from the .jar as the proper content-type? Looking around at configurations I don't see a way to do it. Also, I can't find the underlying code that powers the extraction from the theme.jar in order to alter the code to figure out this content-type. I realize I can just drop the PIE.htc somewhere on the webserver and point to it outside of the theme jar, but that makes this code much less portable and therefore eliminates a pretty good portion of our logic to use the theme jar at all.

Please note: we're serving this up on Tomcat, and I've already checked web.xml to make sure text/x-component is bound, which it is (which is obviously the case or else the second wget wouldn't have turned out what it did).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

り繁华旳梦境2024-11-11 14:40:05

因此,我尽可能快速、轻松地找到了满足我需求的解决方法。
基本上,我只是用behavior.htc.dsp 文件替换了behavior.htc 文件,并将以下行添加到顶部:

<%@ page contentType="text/x-component;charset=UTF-8" %> 

我最初的担心是 IE 不会因为扩展名而将其解析为正确的文件类型,但显然所有它关心标头中的内容类型,所以这有效。

So I discovered the workaround that fit my needs as quickly and easily as possible.
Basically, I just replaced the behavior.htc file with a behavior.htc.dsp file, and added the following line to the top:

<%@ page contentType="text/x-component;charset=UTF-8" %> 

My initial fear was that IE would not parse this as the proper filetype because of the extension, but apparently all it cares about it the content-type in the header, so this worked.

迎风吟唱2024-11-11 14:40:05

您可以提供 EL 函数(例如 c:encodeURL)来自己手动指定内容类型。
您可以参考定义函数的教程

You can provide a EL function like c:encodeURL to manually specify the content type yourself.
You may refer to this tutorial of Defining Functions .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文