2012-04-17 5 views
2

私はspring-mvcとjquery uploadifyを使用して画像をアップロードしています。アップロードスクリプトは画像を保存しています。画像は保存されていますがアップロードされてHTTPエラーが発生しています。発砲した。私は自分のスクリプトが何かを返すようにした。ここに私のコードです。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

上記の実装の主な問題点は、私の春のセキュリティは何とか異なるセッションIDを作成していたし、私の要求が認証されていませんでした理由がある、セッションIDとありました。私はこの

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

ように私の春のセキュリティ設定ファイルからセキュリティを削除し、私はその後、いくつかの他の問題に直面していましたが、私は適切にセッションを処理することによって、この言った問題が回避されています。

関連する問題