2016-10-24 22 views
0

私はxcel生成のためのコードを開発しており、apache poiを使用してダウンロードしています。 LocalHostサーバーとアプリケーションサーバーはjbossです。 localhostでコードを実行すると、jbossのデプロイメントフォルダにtempフォルダが生成され、xcelが生成されてフロントエンドからダウンロードされます。私はJavaのspringJavaとHTMLを使用しています。これはlocalhost上で正常に動作しますが、アプリケーションサーバーにデプロイした後はxcelはダウンロードされず、500:内部サーバーエラーが発生します。コードはlocalhost上でアプリケーションサーバー上で実行されません

angularjsコントローラコード:

$scope.generateExcel=function(sDate,eDate,doc,search) 
{ 
    console.log("hello"); 

    var sDate = document.getElementById('sD').value 
    var eDate = document.getElementById('eD').value 

    $scope.obj.sDate = sDate; 
    $scope.obj.eDate = eDate; 
    $scope.obj.iou = doc; 
    $scope.obj.du = search; 
    console.log($scope.obj); 


    $http.post('abc/generateExcel',$scope.obj).then(function() 
      { 
       //console.log(path); 
       $window.location.href="/ProjectName/file_name.xls"; 
      }) 
    .error(function() 
    { 
     console.log("Error!!"); 
    }); 
}; 

Javaコード: //メソッド

public HttpServletResponse generateExcel (HttpServletRequest request , HttpServletResponse response, String sD, String eD, String doc, String search) 
{ 
    //EXCEL GENERATION HERE 

    response.setContentType("application/vnd.ms-excel"); 
    response.setHeader("Content-Disposition", "attachment;filename=filename.xls"); 
     //Path Specification 
       String path = request.getRealPath("/file_name.xls"); 
       //System.out.println("Here..."); 
       System.out.println(path); 
       FileOutputStream fileOut2 = new FileOutputStream(path); 

       workbook.write(fileOut2); 

      /*returning response*/ 
} 
+1

「500:内部サーバーエラー」「サーバー上で何かが間違っています。サーバーログを調べます。 – talex

+1

エラーのようにあなたのonerrorに渡します。 '.error(function(e){console.log(e);});' –

+0

サーバログには何もなく、またProjectNameとファイルの一時フォルダも生成されませんアプリケーションサーバーのjboss。すべてのパーミッションはサーバ上のjbossフォルダに与えられます。 @talex – Sam

答えて

0

それは1は、サーバー側で取得しているエラーが何を知っていなければ、これを答えることは困難です。サーバーコードをtry-catchブロックに入れます。コードを再実行し、サーバーログを確認します。ここに貼り付けてください。

try{ 
    String path = request.getRealPath("/file_name.xls"); 
      //System.out.println("Here..."); 
      System.out.println(path); 
      FileOutputStream fileOut2 = new FileOutputStream(path); 

      workbook.write(fileOut2); 
    } catch(Exception e){ 
    e.printStackTrace(); // this should print some error in server logs 
    } 
関連する問題