我想通过Angularjs在我的Model
中发布一个文件(multipartFile)这是我的控制器型号
$scope.modelDomain = {};
$scope.modelDomain.id = compose.id;
$scope.modelDomain.title = compose.title;
$scope.modelDomain.message = compose.message;
// a file to upload inside my model
$scope.modelDomain.file = compose.file;
Angular服务:
angular.module('SecureApp')
.service('Publishing', function ($resource) {
return $resource(
'http://localhost:8080/ServerApp/rest/secure/domain',
{modelDomain:'@modelDomain'},
{
save: {
method: 'POST',
params: {modelDomain:'@modelDomain'},
transformRequest: angular.identity,
headers: {'Content-Type': undefined},
}
});
})
Spring服务器
@RequestMapping(value = "/rest/secure/domain", method = RequestMethod.POST)
@ResponseBody
public BufferPublishing newBuffer(@RequestParam ModelDomain modelDomain, HttpServletRequest request){
....
}
服务器模型
public class ModelDomain implements Serializable{
private static final long serialVersionUID = 7208838545241745827L;
Integer id;
String title;
String message;
CommonsMultipartFile file;
它不起作用, 服务器端没有接到客户端呼叫。 一些建议?