티스토리 뷰

spring 프레임웍을 이용하여 파일 업로드를 구현하는데


ERR_CONNECTION_RESET 에러가 날 경우 다음을 체크해보자.


폼을 날리는 소스는 아래와같은 형태로 한다.


var frm = document.getElementById('frm_fileupload');

frm.method = 'POST';

frm.enctype = 'multipart/form-data';

var fileData = new FormData(frm);


$.ajax({

url : "${contextPath}/system/impexp/upload",

type: "POST",

data: fileData,

async: false,

cache: false,

contentType: false

processData: false,

success : function(data){

//성공시 처리 결과 및 다음 스텝 코딩

}).done(function(data, textStatus) {

//console.log("Submit form ajax done");

}).fail(function(jqXHR, textStatus, error){

console.error('Submit failure: ', textStatus, 'error: ', error, jqXHR);

});


그런데 만약 이렇게 했는 데 xmlhttprequest failed to load xxxx 에러가 난다면


acync: true로 변경하면 된다.


아무튼 다시 ERR_CONNECTION_RESET 에러를 처리하기 위해 위와 같이 했는데도


에러가 나다면 첨부파일의 사이즈를 확인해보자. 


프로젝트 셋팅 시 max file upload size보다 크게되면 이런 에러가 난다.


보통은 context-servlet.xml 또는 context-common.xml 에서 설정하는데 잘 모르겠으면


File Search(컨트롤 + H) 에서 multipartResolver 를 검색해보면 아마 나올 것이다.


거기에서 "maxUploadSize" 값을 늘려주면 된다.


나의 경우에는 아래와 같이 셋팅 되어있다.


<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">

    <property name="maxUploadSize" value="104857600" />

    <property name="maxInMemorySize" value="100000000" />

    <property name="defaultEncoding" value="UTF-8"/>

  </bean>



공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함