2013-07-12 2 views
0

JSP로 여러 파일을 업로드하는 방법은 무엇입니까?JSP로 여러 파일 업로드

양식을 제출할 때 다음 질문이 8 개 있습니다. 각 질문마다 첨부 파일을 보내고 싶습니다. 다음 오류가 나타납니다. 이 내 입력 유형이

"Caused by: java.lang.IllegalArgumentException: Cannot invoke 
    com.usrinfo.form.AssessmentForm.setAttatchment on bean class 
    'class com.usrinfo.form.AssessmentForm' - argument type mismatch - 
    had objects of type "java.util.ArrayList" but expected 
    signature "org.apace.struts.upload.FormFile" 

해결을 도와주세요 :이 메시지에 따라 내 행동

action="xxx.do" method="post" enctype="multipart/form-data"> 
+0

이 경우 코드 조각을 표시 할 수 있습니까? – mthmulders

+0

action = "xxxxx.do"method = "post"enctype = "multipart/form-data"> 오류를 표시하는 bean 클래스로 보내는 동안 bean 클래스는 다음과 같다 : private FormFile attachment; \t \t 공개 내고 formfile getAttachment() { \t \t 창 부착; \t} \t \t 공개 무효 setAttachment (내고 formfile 첨부) { \t \t this.attachment = 첨부; \t} } 미리 감사드립니다. – user2575422

+0

코드를 올바르게 표시하십시오. –

답변

1

입니다

<input class="" type='file' style="display:none;" name="attachment" id="<%=q.getId()%>file"/> 

, 스트럿츠는 에 설정하려고 AssessmentForm이지만 AssessmentForm 클래스는 setAttachment(FormFile)입니다. 으로 변경하면, Struts는 FormFiles의리스트를 설정할 수있게되고, 그것을 처리하기 위해 반복 할 수 있습니다.

+0

@mthmulders에게 감사드립니다. 목록을 사용하여이 문제를 해결했습니다. user2575422

+0

도와 주시겠습니까? 그리고 Stack Overflow를 환영합니다. 이 답변 또는 다른 사람이 문제를 해결 한 경우이를 수락 한 것으로 표시하십시오. – mthmulders

+0

나는이 "B @ 5c3dad"와 같은 파일 데이터를 가지고있다. 실제 데이터를 검색하는 방법 – user2575422