我们在 Websphere Portal Server 上部署了几个 portlet。在 css 文件中,我们为 img 标签包含了一个行为属性。
img {
position:relative;
border:none;
outline:none;
behavior: expression((this.runtimeStyle.behavior="none")&&(this.pngSet?this.pngSet=true:(this.nodeName == "IMG" && this.src.toLowerCase().indexOf('.png')>-1?(this.runtimeStyle.backgroundImage = "none", this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "', sizingMethod='image')", this.src = "transparent.gif"):(this.origBg = this.origBg? this.origBg :this.currentStyle.backgroundImage.toString().replace('url("', '').replace('")', ''), this.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.origBg + "', sizingMethod='crop')", this.runtimeStyle.backgroundImage = "none")), this.pngSet=true) );
}
我们发现这个行为标签会导致多个 HTTP 请求。在其中一个 Portlet JSP 中,我们包含了一个样式类,如下所示
<link rel="stylesheet" type="text/css" title="Style"
href=''<%=request.getContextPath()+"/theme/stylesheet.css" %>'>
只有当我们有 request.getContextPath() 时,问题才会出现。如果我将其替换为实际的上下文根,则不会出现问题。有人可以让我知道为什么该行为属性会导致问题吗?