我的Grails应用程序中有一个Service
尝试读取配置,如下所示:
MyService {
def grailsApplication
def myMethode(params){
def var = grailsApplication.config.com.application.document.extension
.....
}
给出以下异常:
no such property : com for class:MyService
Config.groovy:
//....
com.application.document.extension= [ 'Image' : [[mimeType:'image/png',extensions: ['png']],
[mimeType:'image/jpeg',extensions:['jpg','jpeg']]],
'Document' : [[mimeType:'application/pdf',extensions:['pdf']],
[mimeType:'application/vnd.ms-powerpoint',extensions:['ppt','pps']],
[mimeType:'application/vnd.openxmlformats- officedocument.presentationml.presentation',extensions:['pptx']],
[mimeType:'application/vnd.ms-excel',extensions:['xls']],
[mimeType:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',extensions:['xlsx']],
[mimeType:'application/msword',extensions:['doc']],
[mimeType:'application/vnd.openxmlformats-officedocument.wordprocessingml.document',extensions:['docx']],
[mimeType:'image/png',extensions:['png']],
[mimeType:'application/postscript',extensions:['ai','eps','psd']],
[mimeType:'application/zip',extensions:['zip']],
[mimeType:'text/plain',extensions:['txt']]]
]
您肯定没有这样的属性com.application.document。在Config.groovy中扩展。