java.io.IOException: Posted content type isn't multipart/form-data 에러좀 해결해 주세요
jsp 부분은
<%@ page contentType="text/html;charset=UTF-8" %> <%@ page import="java.util.ArrayList" %> <%@ page import="java.util.List" %> <%@ page import="com.sinc.common.FileDTO" %> <%@ page import="com.sinc.common.CodeParamDTO" %> <%@ include file = "/jsp/back/common/commonInc.jsp" %> <%@ page import="org.apache.commons.configuration.Configuration" %> <%@ page import="com.sinc.framework.configuration.ConfigurationFactory" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META http-equiv=Content-Type content="text/html; charset=UTF-8"> <% String v_grcode = box.getString("p_grcode"); String v_year = box.getString("p_year"); String v_subj = box.getString("p_subj"); String v_subjseq = box.getString("p_subjseq"); String v_seq = box.getString("p_seq"); String v_process = box.getString("p_process"); String v_pageno = box.getStringDefault("p_pageno","1"); %> <fmtag:csscommon point="back" /> <fmtag:jscommon /> <script type="text/javascript"> function studyNoticeBoardBatchWrite() { var f = document.form1; var pf = opener.document.form1; if ( !validate(f) ) return; if ( !validateEtc(f) ) return; var arrSubjSeqList = new Array(); var j = 0; var v_subjseqlist = pf.p_subjseqlist; for ( var i=0; i < v_subjseqlist.length; i++ ) { if ( v_subjseqlist[i].checked ) { arrSubjSeqList[j++] = v_subjseqlist[i].value; } } if ( v_subjseqlist.length == undefined ) { arrSubjSeqList[0] = v_subjseqlist.value; } if ( confirm("등록하시겠습니까?") ) { f.p_subjseqlist.value = arrSubjSeqList.toString(); f.submit(); } } function validateEtc(f) { var contents = FCKeditor("p_contents"); if(contents == "") { alert("내용을 입력하세요."); return false; } if(f.p_types.value == "") { alert("공지구분을 선택하세요."); return false; } return true; } function addVariable(str) { var oEditor = FCKeditorAPI.GetInstance("p_contents") ; contents = oEditor.GetData() + " " + str; oEditor.SetData(contents); } function clipboard(str) { window.clipboardData.setData('Text',str); alert("복사되었습니다.사용하실위치에 붙여넣으세요."); } </script> </HEAD> <BODY leftMargin="0" topMargin="0" marginheight="0" marginwidth="0"> <form name="form1" action="/back/StudyNoticeBoard.do" method="post" enctype="multipart/form-data"> <input type="hidden" name="cmd" value="studyNoticeBatchWrite" /> <input type="hidden" name="p_grcode" value="<%=v_grcode%>" /> <input type="hidden" name="p_year" value="<%=v_year%>" /> <input type="hidden" name="p_subj" value="<%=v_subj%>" /> <input type="hidden" name="p_subjseq" value="<%=v_subjseq%>" /> <input type="hidden" name="p_subjseqlist" value="" /> <!-- <table width="800" cellpadding="0" cellspacing="0"> --> <table width="1300" cellpadding="0" cellspacing="0"> <tr> <!-- <td align="center"> --> <td align="left"> <!-- 현재위치 --> <table width="760" cellpadding="0" cellspacing="0" class="mar_top_10"> <tr> <td> + <%=s_menunavi %></td> </tr> </table> <!-- // --> <!-- 메뉴명 --> <table width="760" cellpadding="0" cellspacing="0" class="mar_top_15"> <colgroup> <col width="10" /> <col width="" /> </colgroup> <tr> <td><img src="/images/back/icon/popup_bullet.gif"></td> <td class="t_title">선택공지등록</td> </tr> </table> <!-- // --> <!-- 입력폼 --> <!-- <table width="760" border="0" cellpadding="0" cellspacing="0" class="mar_top_5"> <colgroup> <col width="540" /> <col width="220" /> </colgroup> --> <table width="1250" border="0" cellpadding="0" cellspacing="0" class="mar_top_5"> <colgroup> <col width="540" /> <col width="220" /> </colgroup> <tr valign="top"> <td> <div class="board-view"> <table width="1030" cellpadding="0" cellspacing="0"> <colgroup> <col width="100" /> <col width="" /> </colgroup> <tr> <th class="th_top_bd">제목</th> <td colspan="3" class="td_top_bd" style="padding:5px;"> <!-- <input name="p_contenttitle" type="text" size="60" dispName="제목" isNull="N" lenCheck="200" maxLength="200" value=""> --> <input name="p_contenttitle" type="text" size="150" dispName="제목" isNull="N" lenCheck="200" maxLength="200" value=""> </td> </tr> <tr> <th>공지구분</th> <td><%=CommonUtil.getCodeListBox("select", "0023", "p_types", "", "", " - 선택 - ")%></td> </tr> <tr> <th>내용</th> <td colspan="3" style="padding:5px;"> <%= CommonUtil.getEditor(request,"p_contents","", "900", "580") %> </td> </tr> </table> </div> </td> <!-- 버튼 --> <table width="760" cellpadding="0" cellspacing="0" class="mar_top_10"> <tr> <td align="right"> <% if ( s_menucontrol.equals("RW") ) { %> <fmtag:button type="1" value="저장" func="studyNoticeBoardBatchWrite()" /> <% } %> <fmtag:button type="1" value="취소" func="window.close()" /> </td> </tr> </table> <!-- // --> </td> </tr> </table> </form> </body> </html>
이부분인데 이페이지는 복수의 게시글을 등록하는 페이지입니다. 이페이지에 첨부파일을 추가할수 있게 짤려고 하는데
오류가 납니다. 관련 .java부분은
/** * 공지사항글을 일괄적으로 차수에 넣어주는 팝업을 띄운다. * @param mapping * @param form * @param request * @param response * @param box * @return * @throws Exception */ public ActionForward studyNoticeBatchWritePop ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, Box box ) throws Exception { String uploadPath = "/board/bbs/"+box.getString("p_year"); int v_maxfilesize = box.getInt("p_maxfilesize"); UploadFiles files = FileUtil.upload(request, uploadPath, v_maxfilesize, false, "A", DateTimeUtil.getDateTime()); try { RequestManager.getMultiBox(box, files.getMultipart()); } catch(Exception e) { } DataSet data = null; String v_process = box.getString("p_process"); ArrayList delFileList = (ArrayList)box.getList("Old_p_file"); String msg = null; String goUrl = ""; int retVal = 0; //첨부파일갯수 = 첨부파일갯수 - 제거파일갯수 (기존에 등록된 파일갯수는 DAO에서 따로 계산해준다.) String v_upfilecnt = Integer.toString(files.getFiles().size() - delFileList.size()); box.put("p_upfilecnt", v_upfilecnt); box.put("p_year", box.getString("p_year")); StudyBbsBoardMgr studyBbsBoardMgr = new StudyBbsBoardMgr(); //파일 업로드 상태를 체크한다.(파일을 등록하지 않을경우도 "S") if(files.getStatus().equals("S") && files.getFiles().size() > 0){ //업로드 파일 리스트를 가져온다. ArrayList fileList = new ArrayList(); HashMap hm = null; UploadFile file = null; //파일을 가져와서 DB작업을 해준다. for(int i=0 ; i<files.getFiles().size() ; i++){ file = (UploadFile)files.getFiles().get(i); hm = new HashMap(); hm.put("p_savefile",file.getUploadName()); hm.put("p_realfile",file.getRootName()); hm.put("p_filesize",Long.toString(file.getSize())); fileList.add(hm); } box.put("FileList", fileList); } if ( files.getStatus().equals("S") ) { if ( v_process.equals("W") ) { retVal = studyBbsBoardMgr.insertStudyBbsBoard(box); if(retVal > 0) { msg = "게시물 등록에 성공하였습니다."; } else { msg = "게시물 등록에 실패하였습니다."; } } else if ( v_process.equals("E") ) { if ( delFileList != null && delFileList.size() > 0 ) { data = studyBbsBoardMgr.selectStudyBbsBoardDelFile(box); if(data != null && data.getRow() > 0) { for(int i=0 ; i<data.getRow() ; i++) { FileUtil.delFile(FileUtil.UPLOAD_PATH + uploadPath + "/" + ((HashMap)data.getDataSet().get(i)).get("SAVEFILE")); } } } retVal = studyBbsBoardMgr.updateStudyBbsBoard(box); if(retVal > 0) msg = "게시물 수정에 성공하였습니다."; else msg = "게시물 수정에 실패하였습니다."; } } else { UploadFile file = null; for(int i=0 ; i<files.getFiles().size() ; i++){ file = (UploadFile)files.getFiles().get(i); FileUtil.delFile(FileUtil.UPLOAD_PATH + uploadPath + "/" + file.getUploadName()); } if(v_process.equals("W")) msg = "한 게시물당 최대 " + v_maxfilesize + "MB까지 파일을 올리실 수 있습니다.\\n게시물 등록에 실패하였습니다."; else if(v_process.equals("E")) msg = "한 게시물당 최대 " + v_maxfilesize + "MB까지 파일을 올리실 수 있습니다.\\n게시물 수정에 실패하였습니다."; } return mapping.findForward("StudyNoticeBatchWritePop"); }
/** * 공지사항글을 일괄적으로 차수에 넣어주는 팝업을 띄운다. * @param mapping * @param form * @param request * @param response * @param box * @return * @throws Exception */ public ActionForward studyNoticeBatchWritePop ( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response, Box box ) throws Exception { String uploadPath = "/board/bbs/"+box.getString("p_year"); int v_maxfilesize = box.getInt("p_maxfilesize"); UploadFiles files = FileUtil.upload(request, uploadPath, v_maxfilesize, false, "A", DateTimeUtil.getDateTime()); try { RequestManager.getMultiBox(box, files.getMultipart()); } catch(Exception e) { } DataSet data = null; String v_process = box.getString("p_process"); ArrayList delFileList = (ArrayList)box.getList("Old_p_file"); String msg = null; String goUrl = ""; int retVal = 0; //첨부파일갯수 = 첨부파일갯수 - 제거파일갯수 (기존에 등록된 파일갯수는 DAO에서 따로 계산해준다.) String v_upfilecnt = Integer.toString(files.getFiles().size() - delFileList.size()); box.put("p_upfilecnt", v_upfilecnt); box.put("p_year", box.getString("p_year")); StudyBbsBoardMgr studyBbsBoardMgr = new StudyBbsBoardMgr(); //파일 업로드 상태를 체크한다.(파일을 등록하지 않을경우도 "S") if(files.getStatus().equals("S") && files.getFiles().size() > 0){ //업로드 파일 리스트를 가져온다. ArrayList fileList = new ArrayList(); HashMap hm = null; UploadFile file = null; //파일을 가져와서 DB작업을 해준다. for(int i=0 ; i<files.getFiles().size() ; i++){ file = (UploadFile)files.getFiles().get(i); hm = new HashMap(); hm.put("p_savefile",file.getUploadName()); hm.put("p_realfile",file.getRootName()); hm.put("p_filesize",Long.toString(file.getSize())); fileList.add(hm); } box.put("FileList", fileList); } if ( files.getStatus().equals("S") ) { if ( v_process.equals("W") ) { retVal = studyBbsBoardMgr.insertStudyBbsBoard(box); if(retVal > 0) { msg = "게시물 등록에 성공하였습니다."; } else { msg = "게시물 등록에 실패하였습니다."; } } else if ( v_process.equals("E") ) { if ( delFileList != null && delFileList.size() > 0 ) { data = studyBbsBoardMgr.selectStudyBbsBoardDelFile(box); if(data != null && data.getRow() > 0) { for(int i=0 ; i<data.getRow() ; i++) { FileUtil.delFile(FileUtil.UPLOAD_PATH + uploadPath + "/" + ((HashMap)data.getDataSet().get(i)).get("SAVEFILE")); } } } retVal = studyBbsBoardMgr.updateStudyBbsBoard(box); if(retVal > 0) msg = "게시물 수정에 성공하였습니다."; else msg = "게시물 수정에 실패하였습니다."; } } else { UploadFile file = null; for(int i=0 ; i<files.getFiles().size() ; i++){ file = (UploadFile)files.getFiles().get(i); FileUtil.delFile(FileUtil.UPLOAD_PATH + uploadPath + "/" + file.getUploadName()); } if(v_process.equals("W")) msg = "한 게시물당 최대 " + v_maxfilesize + "MB까지 파일을 올리실 수 있습니다.\\n게시물 등록에 실패하였습니다."; else if(v_process.equals("E")) msg = "한 게시물당 최대 " + v_maxfilesize + "MB까지 파일을 올리실 수 있습니다.\\n게시물 수정에 실패하였습니다."; } return mapping.findForward("StudyNoticeBatchWritePop"); }
이부분 입니다.
public ActionForward studyNoticeBatchWrite이부분에 첨부파일 기능을 넣을려고 하는데 오류가 나네요 jsp페이지에 enctype="multipart/form-data"> 해줬는데 왜 그러죠?
오류 메세지는
java.io.IOException: Posted content type isn't multipart/form-data
at com.oreilly.servlet.multipart.MultipartParser.(MultipartParser.java:166)
at com.oreilly.servlet.MultipartRequest.(MultipartRequest.java:222)
at com.sinc.framework.util.FileUtil.upload(FileUtil.java:731)
at com.sinc.lms.study.StudyNoticeBoardBaction.studyNoticeBatchWritePop(StudyNoticeBoardBaction.java:456)
at sun.reflect.GeneratedMethodAccessor57.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sinc.framework.struts.DispatchAction.dispatchMethod(DispatchAction.java:163)
at com.sinc.framework.struts.StrutsDispatchAction.execute(StrutsDispatchAction.java:58)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:237)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at com.sinc.framework.struts.StrutsReloadActionServlet.process(StrutsReloadActionServlet.java:72)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sinc.framework.util.CommonInterceptor.doFilter(CommonInterceptor.java:62)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.sinc.framework.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:105)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
입니다
댓글 달기