나는 간단한 grails 파일 업로드 응용 프로그램을 가지고 있습니다.grails base.dir 시스템 속성
transferTo를 사용하여 파일을 파일 시스템에 저장하고 있습니다.
내가 내 6.1 WAS 서버에 배포 할 때 항상 null의 몇 가지 이유를 들어def basePath = System.properties['base.dir'] // HERE IS HOW I GET IT
println "Getting new file"
println "copying file to "+basePath+"/files"
def f = request.getFile('file')
def okcontents = ['application/zip','application/x-zip-compressed']
if (! okcontents.contains(f.getContentType())) {
flash.message = "File must be of a valid zip archive"
render(view:'create', model:[zone:create])
return;
}
if(!f.empty) {
f.transferTo(new File(basePath+"/files/"+zoneInstance.title+".zip"))
}
else
{
flash.message = 'file cannot be empty'
redirect(action:'upload')
}
println "Done getting new file"
을 사용하고 내 컨트롤러의 기본 경로를 얻으려면.
dev를 실행하지만 WAS 서버에서 성능이 저하되지 않는 이유는 무엇입니까? 이 정보에 다른 방식으로 액세스해야합니까?
이 현재 허용 대답보다 갈 수있는 더 좋은 방법입니다. –