【问题标题】:can't resolve path to PIE.htc无法解析 PIE.htc 的路径
【发布时间】:2012-02-14 17:18:00
【问题描述】:

我正在尝试将 css3pie 与 Grails 应用程序集成。根据the instructions,我需要做的就是:

  • 将 PIE.htc 文件放在服务器上的某个位置
  • 将以下内容添加到每个相关的 CSS 规则 behavior: url(path/to/PIE.htc);

为了简化查找​​ PIE.htc 的路径,我将文件放在web-app/js/PIE.htc。然后我定义了以下 URL 映射

"/PIE.htc"(controller: 'home', action: 'css3pie')

由动作处理:

class HomeController implements ApplicationContextAware {

    private ResourceLoader resourceLoader

    void setApplicationContext(ApplicationContext applicationContext) {
        this.resourceLoader = applicationContext
    }

    def css3pie() {
        log.debug "css3pie HTC file requested"
        Resource pieHTC = resourceLoader.getResource('/js/PIE.htc')
        response.contentType = 'text/x-component'
        response.outputStream << pieHTC.file.text
        response.outputStream.flush()
    }
}

如果您导航到http://summer-festivals.cloudfoundry.com/PIE.htc,文件就会被提供,所以一切似乎都在工作。然后我将 behavior 属性添加到一些 CSS 规则中,以查看它是否有效,例如

.roundBottomLeft {
    border-bottom-left-radius: 10px;
    -moz-border-radius-bottomleft: 10px;
    behavior: url(/PIE.htc);
}

.roundBottomRight {
    border-bottom-right-radius: 10px;
    -moz-border-radius-bottomright: 10px;
    behavior: url(/PIE.htc);
}

这应该围绕菜单的右下角和左下角,但如果您在 IE8 中查看homepage,您会发现它不起作用。

我似乎在解析PIE.htc 文件的路径时出现问题,因为我在上面的css3pie 操作中设置了一个断点,但断点从未命中。为什么没有解析到PIE.htc 的路径。

【问题讨论】:

  • 我遇到了 PIE.htc 之前没有被调用的问题。试着把它放在你的根文件夹中。另外我认为路径总是相对于根目录而不是实际文件夹。所以behavior: url(PIE.htc) 会在根目录中查找它,即使它是从../css 内部调用的
  • 唐 -- 我也遇到过类似的问题,即 Internet Explorer 无法获取 PIE.htc,即使我尝试各种路径并将 PIE.htc 复制到多个目录,例如webapp 和 webapp/css。它似乎在某些 gsps 中有效,而在其他 gsps 中则无效,即使它是完全相同的 css 元素。您是否能够解决常规样式表使用的路径问题?如果是这样,如果您发布答案,我将不胜感激。
  • @Ray 不,我放弃了 PIE.htc,因为它似乎造成的问题多于解决的问题

标签: css internet-explorer grails css3pie


【解决方案1】:

根据文档,PIE 仅识别速记样式。因此,您需要将border-radius 与每个角的速记值一起使用,而不是单独的border-x-y-radius 属性。

http://css3pie.com/documentation/known-issues/#shorthand

http://css3pie.com/documentation/supported-css3-features/#border-radius

【讨论】:

    【解决方案2】:

    试试这个,我刚刚修改了你的代码:

    URLMappings.groovy

    class UrlMappings {
        static mappings = {
            "/$controller/$action?/$id?"{
                constraints {
                    // apply constraints here
                }
            }
            "/"(controller:'home')
            "500"(view:'/error')
            "403"(view:'/login/denied')
            "/static/PIE.htc"(controller: 'home',action: 'css3pie') // <== see here
        }
    }
    

    HomeController.groovy

    import grails.plugins.springsecurity.Secured
    import org.springframework.core.io.Resource
    
    @Secured("IS_AUTHENTICATED_FULLY")
    class HomeController {
    
        def grailsApplication
    
        def index = { }
    
        def css3pie() {
            Resource pieHTC = grailsApplication.mainContext.getResource('css/PIE.htc') // <== see here
            response.contentType = 'text/x-component'
            response.outputStream << pieHTC.file.text
            response.outputStream.flush()
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-28
      • 1970-01-01
      • 2017-12-15
      • 2019-08-18
      相关资源
      最近更新 更多