메뉴 건너뛰기

목록
profile
조회 수 197 댓글 8 예스잼 0 노잼 0

No Attached Image

서블릿 컨텍스트에는

<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
        <beans:property name="maxUploadSize" value="200000000" />
        <beans:property name="maxInMemorySize" value="200000000" />
    </beans:bean>

등록시켜놨고

 

 

form 데이터 보낼때는 멀티파트 지정했는데

<form style="font-weight:bold;" encType="multipart/form-data">

 

 

 

돌아오는건 시발 에러네 ㅡㅡ

 cannot be cast to org.springframework.web.multipart.MultipartHttpServletRequest

 

혹시 아는수붕이 있나

 

 

혹시나해서ajax 하고 service구문도 올려봄

 

$.ajax({
                    url : '/common/insertFileInfo',
                    type: 'POST',
                    processData: false,
                    contentType: false,
                    data: fileData,
                    success: function(data) {
                        if(data.result == 200){
                            alert(data.message);
                            location.reload(true);
                        }
                    },
                    error: function(x, e) {
                        alert("대충 에러떴다는 거");
                        return false;
                    }
                });

 

 

 

@Override
    public Map<String, Object> insertFileInfo(Map<String, Object> map, HttpServletRequest request) throws Exception {
        MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest)request;
        Iterator<String> iterator = multipartHttpServletRequest.getFileNames();
        MultipartFile multipartFile = null;
       
        while(iterator.hasNext()){
            multipartFile = multipartHttpServletRequest.getFile(iterator.next());
            if(multipartFile.isEmpty() == false){
                log.debug("------------- file start -------------");
                log.debug("name : "+multipartFile.getName());
                log.debug("filename : "+multipartFile.getOriginalFilename());
                log.debug("size : "+multipartFile.getSize());
                log.debug("-------------- file end --------------\n");
               
            }
           
        }
       
        return map;
       
    }

 

  • profile
    스마일 2020.08.12 18:51
    Content type false 라서 그런거 아님?
  • profile
    스마일 2020.08.12 18:52
    4시간 전이면 벌써 고쳤겠지
  • profile
    阿米娅 2020.08.12 18:54
    삽질존나하다가 안되서 jquery form 플러그인으로 ajaxform 보내는걸로 변경했어
  • profile
    阿米娅 2020.08.12 18:55
    파일 있을경우에 파일첨부 먼저돌리고 그 이후에 성공하면 업데이트 치는식으로 어거지로끼워맞춤
  • profile
    스마일 2020.08.12 19:23
    옛날 코드들 있으면 보고 얘기해주려고 했는데 없노ㅋㅋㅋ
  • profile
    스마일 2020.08.12 20:03
    근데 @RequstMapping 같은건 잘 되어있노?
  • profile
    阿米娅 2020.08.12 20:04
    응 다 되어있고 파라미터받는것도 문제없는데
    저 multipart때문에 기존에 쓰던@annotation session하고 request까지 싹다 바꿈
  • profile
    스마일 2020.08.12 20:12
    HttpServletRequest 를 MultipartHttpServletRequest 넣어서 받음 안되나 캐스팅 다 때려치고

List of Articles
번호 제목 글쓴이 날짜 조회 수 추천
공지 수용소닷컴 이용약관 file asuka 2020.05.16 1340 1
» 스프링에서 파일업로드 개발하는데 왤케 에러나냐 8 阿米娅 2020.08.12 197 0
975 본인 신남 clownpepe 2020.08.12 55 0
974 컴돌이 ㅎㅌㅊ가 회사 들어가려면 2 그라드 2020.08.13 97 0
973 github profile 기능이 생겼었네 clownpepe 2020.08.13 47 0
972 공부하고 싶은 게 노무 많은데 2 file clownpepe 2020.08.13 72 0
971 하드디스크 오류 질문 44 file 의찬이 2020.08.14 107 0
970 삭제된 게시글입니다. 스마일 2020.08.14 59 0
969 fira code font clownpepe 2020.08.14 48 0
968 하 elasticbeanstalk 딱 좋은 데 왜 cli가 안 먹노 file clownpepe 2020.08.15 59 0
967 삭제된 게시글입니다. 스마일 2020.08.15 52 0
966 고성능 겜트북 필요없는듯 2 그라드 2020.08.16 81 0
965 삭제된 게시글입니다. 스마일 2020.08.17 113 0
964 삭제된 게시글입니다. 스마일 2020.08.17 74 0
963 삭제된 게시글입니다. 스마일 2020.08.18 54 0
962 생각해보니까 풀스택 개발자라는것도 4 阿米娅 2020.08.18 72 0
961 삭제된 게시글입니다. 스마일 2020.08.20 80 0
960 삭제된 게시글입니다. 스마일 2020.08.20 57 0
959 삭제된 게시글입니다. 스마일 2020.08.21 81 0
958 삭제된 게시글입니다. 스마일 2020.08.21 51 0
957 toast ui 참 좋습니다. 2 clownpepe 2020.08.21 64 0
목록
Board Pagination Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 56 Next
/ 56