Java xlsx文件在http请求中发送时已损坏/为空(0字节)

Java xlsx文件在http请求中发送时已损坏/为空(0字节),java,angularjs,rest,jsp,apache-poi,Java,Angularjs,Rest,Jsp,Apache Poi,我正在通过http请求发送xlsx文件,但该文件已损坏。 我只是不明白为什么文件在发送时会损坏。 请帮忙,我是新手 以下是jsp文件: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html ng-app="myApplication"> <head> <!-- <meta http-e

我正在通过http请求发送xlsx文件,但该文件已损坏。 我只是不明白为什么文件在发送时会损坏。 请帮忙,我是新手

以下是jsp文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html ng-app="myApplication">

<head>
<!-- <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> -->

<title>Preptune</title>

 <meta name="viewport" content="width=device-width, initial-scale=1">
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script>

   angular.module('myApplication',["ngRoute"]).
   directive('fileInput',['$parse',function($parse){
    return {
        restrict:'A',
        link: function(scope,elm,attrs) {
            elm.bind('change',function() {
                $parse(attrs.fileInput)
                .assign(scope,elm[0].files)
                scope.$apply()
            })
        }
    }
   }])
   .controller('myController',['$scope','$http',
                function($scope,$http) {
    $scope.message = "Test message";
    $scope.filesChanged = function(elm) {
        $scope.files=elm.files;
        $scope.$apply();
    };
    $scope.upload = function() {
        var fd = new FormData();
        angular.forEach($scope.files,function(file){
            fd.append('file',file);
        })
        $http.post('http://localhost:80/simple-web-services/uploadQuestions', fd,{
            transformRequest : angular.identity,
            headers:{'Content-Type':undefined}
        })
        .success(function(d){
            console.log(d);
        })
    };
     }
   ])
   .config(function($routeProvider) {
        $routeProvider
        .when("/preptune", {
            templateUrl : "/webPortal/homePage/welcome"
        })
        .when("/upload", {
            templateUrl : "/webPortal/resources/html/uploadQuestion.html"
        })
        .when("/download", {
            templateUrl : "/webPortal/resources/html/downloadTemplate.html"
        })
        .otherwise({redirectTo:'/'});
    });

  </script>
</head>
<body ng-controller="myController">

<nav class="navbar navbar-default">
  <div class="container-fluid bg-info">
    <div class="navbar-header">
      <a class="navbar-brand" href="#prep">Prep</a>
    </div>
    <ul class="nav navbar-nav">
      <li><a href="#upload">Upload Question Paper</a></li>
      <li><a href="#download">Download Question Template</a></li>
    </ul>
  </div>
</nav>

<div ng-view></div>

</body>
</html>

预调
角度.module('myApplication',[“ngRoute”])。
指令('fileInput',['$parse',函数($parse){
返回{
限制:'A',
链接:功能(范围、elm、属性){
elm.bind('change',function(){
$parse(attrs.fileInput)
.assign(作用域,elm[0]。文件)
范围:$apply()
})
}
}
}])
.controller('myController',['$scope','$http',
函数($scope,$http){
$scope.message=“测试消息”;
$scope.filesChanged=函数(elm){
$scope.files=elm.files;
$scope.$apply();
};
$scope.upload=函数(){
var fd=新FormData();
angular.forEach($scope.files,function(file){
fd.append('file',file);
})
$http.post('http://localhost:80/simple-web服务/上传问题”,fd{
请求:angular.identity,
标题:{'Content-Type':未定义}
})
.成功(功能(d){
控制台日志(d);
})
};
}
])
.config(函数($routeProvider){
$routeProvider
.when(“/preptune”{
templateUrl:“/webPortal/homePage/welcome”
})
.when(“/upload”{
templateUrl:“/webPortal/resources/html/uploadQuestion.html”
})
.when(“/下载”{
templateUrl:“/webPortal/resources/html/downloadTemplate.html”
})
。否则({重定向到:'/'});
});
这是表格:(uploadQuestion.html)


上传
  • {{file.name}
  • 例外情况是
    java.lang.RuntimeException:org.apache.cxf.interceptor.Fault:您的InputStream既不是OLE2流,也不是OOXML流

    您能够解决这个问题吗?您能够解决这个问题吗?
    <form method="post">
    <input type="file" 
    file-input="files"
     multiple></input>
    <button ng-click="upload()"> Upload </button>
     <li ng-repeat="file in files" >{{file.name}} </li>
    </form>