打开grails插件目录,打开ckeditor,找到grails-app/controllers/org.gualdi.grails.plugins.ckeditor/StandardFileManagerConnectorController
然后找到里面的,文件保存代码:
if (FileUtils.isAllowed(f.ext, type)) {
/*修改上传文件的命名方式《下面这段代码为,自己添加的,用来改变文件命名方式,这样就可以解决中文乱码了》*/ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmssSSSS"); newName = formatter.format(new Date())+"."+f.ext;
def fileToSave = new File(finalDir, newName) if ( !overwrite ) { def idx = 1 while (fileToSave.exists()) { errorNo = this.ERROR_FILE_RENAMED newName = "${f.name}(${idx}).${f.ext}" fileToSave = new File(finalDir, newName) idx++ } } file.transferTo(fileToSave) } else { errorNo = this.ERROR_INVALID_FILE_TYPE errorMsg = "INVALID FILE TYPE" }
?