在Grails中从'src'解析'web-app / file / misc'的路径 [英] Resolving the path of 'web-app/file/misc' from 'src' in Grails

查看:126
本文介绍了在Grails中从'src'解析'web-app / file / misc'的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在'src'目录下创建了一个类。我使用这段代码访问'grails-app'中所有文件的'images'目录:

  ApplicationHolder.application .parentContext.getResource( 文件/ MISC)文件。 

我在'src'类中访问它时遇到此错误:

 应用程序在org.codehaus.groovy.grails.commons.ApplicationHolder中有私人访问权限

对此有何评论?如何在应用程序部署到tomcat时访问file / misc?

解决方案

看起来我已经解决了它: (); getBileContext()。getResource(file / recsys)。getFile();

我习惯了Groovy语法,开始忘记常规的Java方法。对不起。

I created a class under 'src' dir. I'm using this code to access the 'images' directory for all files inside 'grails-app':

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

I'm having this error when I access it in a 'src' class:

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

Any comment on why is this happening? How can I access "file/misc" when app is deployed to tomcat?

解决方案

Looks like I solved it already:

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

I'm getting used to Groovy syntax, starting to forget regular Java methods. Sorry.

这篇关于在Grails中从'src'解析'web-app / file / misc'的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆