2010-04-06 39 views
0

我在'src'目錄下創建了一個類。我使用這個代碼來訪問「的grails-app」裏面所有文件的「圖片」目錄:在Grails中從'src'解析'web-app/file/misc'的路徑

ApplicationHolder.application.parentContext.getResource("file/misc").file; 

我有,當我訪問它的「SRC」類此錯誤:

application has private access in org.codehaus.groovy.grails.commons.ApplicationHolder 

對此問題的評論爲何這樣?如何在應用程序部署到tomcat時訪問「file/misc」?

回答

1

貌似我解決它已經:

ApplicationHolder.getApplication().getParentContext().getResource("file/recsys").getFile(); 

我習慣Groovy的語法,開始忘記常規的Java方法。抱歉。

0

從GSP頁面,你可以做

$ {資源(導演: '圖像',文件: 'example.gif')}