2
파일을 업로드하고 파일에 저장하려고합니다. 컨트롤러에서파일 업로드가 발생 함 메서드 예외의 서명이 없습니다 (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)
}
, 난 여기에 예외를 가지고 이것은 GSP의 코드입니다. 어떤 도움이 필요합니까? 감사. (요청에 의해 전체 스택 트레이스)
편집 :
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 버전 문제일까요? Im on 2.0.4 – Fustigador
어쩌면 'grails clean'시도 – Dopele