2012-02-14 78 views
0

我正嘗試將css3pie與Grails應用程序集成。據the instructions,所有我需要做的是:無法解析路徑到PIE.htc

  • 地方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的路徑。

+0

我有PIE.htc以前沒有被調用的問題。嘗試將其放入根文件夾中。另外我認爲路徑總是相對於根而不是實際的文件夾。所以'行爲:url(PIE.htc)'會在根目錄下查找它,即使它是從'../ css'內調用的。 – elclanrs 2012-02-14 18:08:50

+0

不 - 我有類似的問題,IE瀏覽器沒有得到PIE.htc,即使當我嘗試各種路徑並將PIE.htc複製到多個目錄中,例如webapp和webapp/css。它似乎在某些gsps中工作,然後不在其他人,即使它是完全相同的CSS元素。您是否可以解決常規樣式表使用的路徑問題?如果是這樣,如果您發佈答案,我一定會很感激。 – Ray 2012-02-18 01:07:51

+0

@ Ray No我放棄了PIE.htc,因爲它似乎導致了比解決問題更多的問題 – 2012-02-18 11:17:52

回答

1

試試這個,我只是修改你的代碼一點點:

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() 
    } 
}