2012-04-17 2 views
2

spring-mvc 및 jquery uploadify를 사용하여 이미지를 업로드하고 업로드 스크립트가 내 서버에 이미지를 저장하고 이미지가 저장되지만 업로드 오류로 인해 HTTP 오류가 발생하고 onComplete가 표시되지 않습니다. 해고 됐어. 내 대본에서 뭔가를 돌려주고 있는지 확인했습니다. 여기 내 코드가있다. Uploadify onComplete가 호출되지 않습니다.

$(document).ready(function() { 
      $('#upload').click(function() { 
       $('#uploadify').uploadifyUpload(); 
        return false; 
       }); 
       $('#uploadify').uploadify({ 
        'uploader': 'js/uploadify/uploadify.swf', 
        'script': 'uploadcreate.htm;jsessionid=${sessionId}', 
        'multi': false, 
        'auto' : true, 
        'fileDesc': 'JPG Image Files (*.jpg),JPG Image Files (*.JPG),JPG Image Files (*.JPEG)', 
        'fileExt' : '*.jpg;*.jpeg;*.JPEG;', 
        'cancelImg': 'js/uploadify/cancel.png', 
        onComplete: function (event, queueID, fileObj, response, data) { 
         alert("as"); 
         //$("#showimage").html('<img src="' + response + '" height="500" width="500" /><br />http://localhost:8080' + fileObj.filePath); 

         } 
       }); 
     }); 

내 컨트롤러 코드는 다음과 같습니다 위의 구현

@RequestMapping(value="/uploadcreate.htm", method = RequestMethod.POST) 
    public JSONObject uploadcreate(UploadProperties uploadbean, BindingResult result, HttpServletRequest request, Model model) { 
     System.out.println("started uploading"); 
     if (result.hasErrors()) { 
      for (ObjectError error : result.getAllErrors()) { 
       System.err.println("Error in uploading: " + error.getCode() 
         + " - " + error.getDefaultMessage()); 
      } 
      return null; 
     } 
     String relativeWebPath = "/WEB-INF/uploads"; 
     String absoluteFilePath = request.getServletContext().getRealPath(relativeWebPath); 
     String username = request.getUserPrincipal().getName(); 

     JSONObject filepath = uploadFacade.upload(uploadbean, username, absoluteFilePath); 

     model.addAttribute("filePath", filepath); 
     return filepath; 

    } 

답변

0

가장 큰 문제는 sessionId가, 내 봄 보안은 어떻게 든 다른 세션 ID를 작성하고로했다 나의 요청이 인증 받고되지 않은 이유입니다. 나는이

<intercept-url pattern="/uploadcreate.htm" filters="none" /> 

처럼 내 봄 보안 구성 파일에서 보안을 제거 그 후 다른 문제에 직면하지만 제대로 세션을 처리하여이 말했다 문제를 우회.

관련 문제