2
我试图上传文件,并将其存储在文件中。这是GSP代码:上传文件抛出方法异常没有签名(在getFile()方法中)
<g:form method="post" enctype="multipart/form-data" action="update">
<input type="file" name="cv" id="cv"/>
<g:actionSubmit action="upload" name="upload" value="Upload" />
</g:form>
在控制器:
def upload(){
def f = request.getFile('cv')
InputStream file = f.inputStream
byte[] bytes = file.bytes
println('bytes: '+bytes)
}
正如我在标题中说,我有一个例外这里。任何帮助?谢谢。
EDIT(全堆栈跟踪,按要求):
Error 500: Internal Server Error
URI
/com.publidirecta.azafatas/azafataCertificada/index
Class
groovy.lang.MissingMethodException
Message
No signature of method:org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper.getFile() is applicable for argument types: (java.lang.String) values: [cv] Possible solutions: getXML(), getPart(java.lang.String), getAt(java.lang.String), getAt(java.lang.String), getLocale(), getJSON()
Around line 1158 of grails-app/controllers/com/publidirecta/AzafataCertificadaController.groovy
1155: def upload(){
1156: println("Acción upload. Params: "+params)
1157: Azafata aza=Azafata.findByUsername(params.user)
1158: def f = request.getFile('cv')
1159: InputStream file = f.inputStream
1160: byte[] bytes = file.bytes
1161: }
Trace
Line | Method
->> 1158 | upload in AzafataCertificadaController.groovy
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
| 908 | run . . in ''
^ 680 | run in java.lang.Thread
我试过了代码,它适用于我,没有看到任何错误。 – Dopele
我也没有看到任何错误,但异常不断发生。 Grails版本问题,也许?即时通2.0.4 – Fustigador
也许尝试'grails干净' – Dopele