2014-01-21 142 views
0

我正在使用GSP资源插件(http://grails.org/plugin/gsp-resources)允许我在我的css文件中使用GSP标签。但是,使用“资源”标签时出现奇怪的错误。下面是导致问题的行:Grails GSP资源插件:资源未找到错误

background: transparent url(${resource(dir: 'static/images', file: 'servererror.png')}) 0.5em 50% no-repeat;

我得到应用以下两个错误启动:

2014-01-21 09:39:03,608 [FileSystemWatcher: files=#248 [email protected]] ERROR resource.ResourceMeta - Resource not found: /static/images/servererror.png Error

2014-01-21 09:39:04,257 [FileSystemWatcher: files=#248 [email protected]] ERROR resource.ResourceMeta - While processing /css/servererror.css, a resource was required but not found: /static/images/servererror.png

资源是存在的。如果我手动输入路径,我可以访问它没有问题。如果我将导致问题的线路移动到“html”gsp文件,它就会起作用。但是,由于Grails无法找到它,因此它不会在css文件中正确放置路径。

任何帮助,高度赞赏。

+0

你有称为静态文件夹?我认为你想使用'$ {resource(dir:'images',file:'servererror.png')}' –

回答

0

你最好的办法是手动在css文件中输入路径。错误的原因是,资源无法处理CSS中的资源标签。

您可以使用Applicationresource.groovy在conf文件夹中注入css文件。

的grails-app/conf目录/ applicationresources.groovy

modules = { 
    application { 
     resource url:'css/servererror.css' 
    } 
}