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*/
}
「500:内部サーバーエラー」「サーバー上で何かが間違っています。サーバーログを調べます。 – talex
エラーのようにあなたのonerrorに渡します。 '.error(function(e){console.log(e);});' –
サーバログには何もなく、またProjectNameとファイルの一時フォルダも生成されませんアプリケーションサーバーのjboss。すべてのパーミッションはサーバ上のjbossフォルダに与えられます。 @talex – Sam