0
我要上传的文件文件上传失败,angularjs春季启动
controller.js
userService.saveProfile($scope.user.profile.companyLogo).then(function(response){
if(response.status==201){
$('#profileModal').hide();
$scope.load();
}
});
service.js
saveProfile:function(logo){
var formData = new FormData();
formData.append("file",logo);
var retVal = $http({
method : 'POST',
url : '/api/user/profile',
transformRequest: angular.identity,
headers: {'Content-Type': undefined},
data: formData
}).then(function(response){
return response;
});
return retVal;
}
Controller.java
@RequestMapping(value="/profile",method = RequestMethod.POST,headers="'Content-Type':'multipart/form-data'")
public ResponseEntity saveProfile(@RequestBody MultipartFile file){
System.out.println(file);
return new ResponseEntity(HttpStatus.CREATED);
}
如果我将标题添加到@RequestMapping我得到404,如果我删除我得到的文件空
请建议我做的正确的方式上传文件
您是否获得了服务内部文件的价值? – Vivz
@Vivz是的,我在服务内获得价值 – poojadave
它是在里面。然后呢? – Vivz